{"id":407,"date":"2019-07-03T19:09:34","date_gmt":"2019-07-03T19:09:34","guid":{"rendered":"http:\/\/fip.r-a-w.org\/?p=407"},"modified":"2019-06-05T19:11:15","modified_gmt":"2019-06-05T19:11:15","slug":"kup-assessments-solid-review","status":"publish","type":"post","link":"https:\/\/fip.r-a-w.org\/?p=407","title":{"rendered":"KUP Assessments &#8211; SOLID Review"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Single Responsibility Principle<\/h2>\n\n\n\n<p>KUP_FACADE filters events and provides access to all the endpoints. This should be changed to classes KUP_Facade KUP_Gatehouse and KUP_Assessments. Created accountCreator interface iAccountCreator that removes the responsibility of creating an account from authentication manager to a seperate class. Added interface iAuthenticationRules. HMAC service has a iMACbuilder interface that builds the MACs whereas the HMAC service requests MACS from the builder and varifies any received MAC matches what is expected. Added interface ISanitiser that is a collection of text sanitisers that an assessmentValidator can use to find e.g any QL queries, HQL, OSQL, NOSQL, Xpath query tampering, XML External Entity attacks, and XML injection attacks in submissions from participants. IinputFilterDatabase has been introduced to limit the size of the templates to a suitable size limit. The filters and interceptors have been changed to classes as they already implement the filter and interceptor interfaces and used at the KUP_Gatehouse.  <\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"251\" data-attachment-id=\"411\" data-permalink=\"https:\/\/fip.r-a-w.org\/?attachment_id=411\" data-orig-file=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?fit=1368%2C490&amp;ssl=1\" data-orig-size=\"1368,490\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"class-diagram25-3-19-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?fit=700%2C251&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?resize=700%2C251&#038;ssl=1\" alt=\"Class Diagram after SRP applied\" class=\"wp-image-411\" srcset=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?resize=1024%2C367&amp;ssl=1 1024w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?resize=300%2C107&amp;ssl=1 300w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?resize=768%2C275&amp;ssl=1 768w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?resize=700%2C251&amp;ssl=1 700w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?resize=1117%2C400&amp;ssl=1 1117w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram25-3-19-1.jpeg?w=1368&amp;ssl=1 1368w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Open-Closed Principle<\/h2>\n\n\n\n<p>Classes eyed to obey this principle are AssessmentManager, AccountManager, AuthenticationManager. Also moved the AssessmentCreator to be directly accessed from KUPAssessments this way the AssessmentManager can be passed directly from within AssessmentCreator and assessmentParticipant ,once wrapped in an AssessmentLibrarian Interface.  <\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"251\" data-attachment-id=\"414\" data-permalink=\"https:\/\/fip.r-a-w.org\/?attachment_id=414\" data-orig-file=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?fit=1368%2C490&amp;ssl=1\" data-orig-size=\"1368,490\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"class-diagram27-3-19\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?fit=700%2C251&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?resize=700%2C251&#038;ssl=1\" alt=\"Class diagram after Open - Closed Principle applied.\" class=\"wp-image-414\" srcset=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?resize=1024%2C367&amp;ssl=1 1024w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?resize=300%2C107&amp;ssl=1 300w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?resize=768%2C275&amp;ssl=1 768w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?resize=700%2C251&amp;ssl=1 700w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?resize=1117%2C400&amp;ssl=1 1117w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram27-3-19.jpg?w=1368&amp;ssl=1 1368w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Liskov substitution principle<\/h2>\n\n\n\n<p>Inheritance is to be generally avoided and interfaces shall be\npreferred.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\nInterface segregation principle &amp; Dependency inversion principle<\/h2>\n\n\n\n<p>Although I cannot see any interfaces to separate out at this stage. I have identified that AccountDatabase, CredentialsDatabase and AssessmentDatabase should be interfaces which allows flexibility if these are injected. Assessments have been changed to a class with build-able components that follow the IassessmentComponent. The IAssessment should also follow the open closed principle.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"254\" data-attachment-id=\"416\" data-permalink=\"https:\/\/fip.r-a-w.org\/?attachment_id=416\" data-orig-file=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?fit=1368%2C497&amp;ssl=1\" data-orig-size=\"1368,497\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"class-diagram1-4-19\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?fit=700%2C254&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?resize=700%2C254&#038;ssl=1\" alt=\"Class Diagram after applying DIP \" class=\"wp-image-416\" srcset=\"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?resize=1024%2C372&amp;ssl=1 1024w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?resize=300%2C109&amp;ssl=1 300w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?resize=768%2C279&amp;ssl=1 768w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?resize=700%2C254&amp;ssl=1 700w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?resize=1101%2C400&amp;ssl=1 1101w, https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/class-diagram1-4-19.jpeg?w=1368&amp;ssl=1 1368w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Single Responsibility Principle KUP_FACADE filters events and provides access to all the endpoints. This should be changed to classes KUP_Facade KUP_Gatehouse and KUP_Assessments. Created accountCreator interface iAccountCreator that removes the responsibility of creating an account from authentication manager to a seperate class. Added interface iAuthenticationRules. HMAC service has a iMACbuilder interface that builds the MACs &hellip; <a href=\"https:\/\/fip.r-a-w.org\/?p=407\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">KUP Assessments &#8211; SOLID Review<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":366,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[2,3,5],"tags":[],"class_list":["post-407","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-decisions","category-oop-design","category-project"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/fip.r-a-w.org\/wp-content\/uploads\/2019\/06\/KUPassessmentLogoDEcorated4-6-19.png?fit=1189%2C599&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9NvWe-6z","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=\/wp\/v2\/posts\/407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=407"}],"version-history":[{"count":7,"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=\/wp\/v2\/posts\/407\/revisions"}],"predecessor-version":[{"id":417,"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=\/wp\/v2\/posts\/407\/revisions\/417"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=\/wp\/v2\/media\/366"}],"wp:attachment":[{"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fip.r-a-w.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}