{"id":1867,"date":"2020-11-16T10:02:48","date_gmt":"2020-11-16T10:02:48","guid":{"rendered":"https:\/\/rentabilitet.dk\/opgaver\/?page_id=1867"},"modified":"2020-11-16T10:02:55","modified_gmt":"2020-11-16T10:02:55","slug":"class-diagram","status":"publish","type":"page","link":"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/","title":{"rendered":"Class diagram"},"content":{"rendered":"<p><strong>Structure<br \/>\n<\/strong> After having established the classes in the system, the structure will now be defined with the<br \/>\nuse of a class diagram.<\/p>\n<p><strong>Theory<br \/>\n<\/strong> The purpose of the class diagram is to describe structural relations between objects and classes<br \/>\nin a problem domain (Lars Mathiassen, 2000, p. 71). The structural relations are different for<br \/>\nthe classes and objects which will be described below.<\/p>\n<p><strong>Class structures<br \/>\n<\/strong> The relations between the classes are abstract, static and general, and can consist of a<br \/>\ngeneralisation. A generalisation is a general class that describes the properties that are common<br \/>\nfor a group of subclasses. Generalisations can be expressed linguistically using the formulation<br \/>\n\u201cis-a\u201d. The subclasses inherits all of the properties and behaviors that the super-class contains<br \/>\n(Lars Mathiassen, 2000, p. 75). A class is abstract if it has no related objects. These classes are<br \/>\nused for descriptive reasons and the class names are written in italic (Lars Mathiassen, 2000,<br \/>\np. 73).<\/p>\n<p><strong>Object structures<br \/>\n<\/strong> The relations between objects are &#8211; opposite to classes &#8211; specific and dynamic, and consists of<br \/>\neither an aggregation or an association. An aggregation structure means that one object is a<br \/>\nfundamental and defining part of the other (Lars Mathiassen, 2000, p. 77). Aggregations can be<br \/>\nexpressed linguistically using the formulation \u201chas-a\u201d (Lars Mathiassen, 2000, p. 78). Likewise<br \/>\nthe classes that are aggregated can be linguistically expressed as \u201cpart-of\u201d or \u201cowned-by\u201d (see<br \/>\nfigure 4.2).<\/p>\n<p>An association structure is much like the aggregation structure, but the difference is that the<br \/>\nassociated objects are not fundamental and defining for one another. Therefore the association<br \/>\nstructure is often used when an aggregation structure would imply a too strong relation<br \/>\n(Lars Mathiassen, 2000, p. 79). The association structure can be linguistically expressed as<br \/>\n\u201cknows\u201d or \u201cassociated with\u201d.<\/p>\n<p>When creating the class diagram it is important to numerate the possible relations. If for<br \/>\nexample object A is an aggregation of zero or more object B\u2019s, this is denoted by &#8220;0..*&#8221;<br \/>\n(Lars Mathiassen, 2000, p. 78).<\/p>\n<p><strong>Creating class diagrams<br \/>\n<\/strong> When the class diagram is being created it is important to only model the necessary structural<br \/>\nrelations (Lars Mathiassen, 2000, p. 86). Likewise the use of generalisations and aggregations should only be applied when they add anything relevant to the description. The names,<br \/>\nconcepts, and structural relations should reflect the users\u2019 understanding of the problem domain.<br \/>\nBut they do not necessarily have to be completely identical (Lars Mathiassen, 2000, p. 87).<br \/>\nThough the best case scenario would be that the problem domain reflects a future user\u2019s<br \/>\nunderstanding of the problem domain.<br \/>\nThe graphical notation of the relation structures between classes is illustrated in figure 4.2.<\/p>\n<p><img loading=\"lazy\" width=\"477\" height=\"163\" class=\"wp-image-1868\" src=\"https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-6.png\" srcset=\"https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-6.png 477w, https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-6-300x103.png 300w\" sizes=\"(max-width: 477px) 100vw, 477px\" \/><br \/>\nFigure 4.2. Graphical notations of structures<\/p>\n<p><strong>Class Diagram Analysis example<br \/>\n<\/strong> In section 4.1.2 we described that our problem domain contains four classes: Employee, Manager,<br \/>\nTeam, and Questionnaire. The employee and manager classes could be described as roles for a<br \/>\nnew general class user. The validity of this choice is tested using the linguistic formulation for<br \/>\naggregations &#8220;has-a&#8221; and the linguistic formulation for generalisations, &#8220;is-a&#8221;. So &#8220;a user has a<br \/>\nrole&#8221; and \u201ca manager is a role\u201d. This confirms that these classes can be roles of a class called<br \/>\nuser. There are no objects related to Role so this is an abstract class, and the class name is<br \/>\ntherefore written in italic in the class diagram.<\/p>\n<p>The primary job for the manager is to compose new teams. The relation between the manager<em><br \/>\n<\/em> class and the team class could therefore be described as an association. They have a meaningful<br \/>\nrelation but one object is not fundamental or defining of the other. This relation is linguistically<br \/>\nexpressed as \u201ca manager is associated with a team\u201d. One team can be managed by one or more<br \/>\nmanagers, while one manager manages zero or more teams. This is respectively denoted as<br \/>\n&#8220;1..*&#8221; and &#8220;0..*&#8221; in the class diagram.<\/p>\n<p>The Team class could be described as an aggregation of employee-objects, because the selected<br \/>\nemployees make up a specific team. Without these employees there would not be a team. The<br \/>\nvalidity of this choice could be tested by using the linguistic formulation for aggregations, &#8220;hasa&#8221; or &#8220;is-part-of&#8221;. So &#8220;a team has an employee&#8221; and &#8220;an employee is part of a team&#8221;. One<br \/>\nemployee can be part of zero or more teams, while one team requires two or more employees.<br \/>\nThe employees fill out questionnaires in order for the managers to collect data about the<br \/>\nemployees competences and personality types. For this reason the employee class is associated<br \/>\nwith the questionnaire class. There are multiple types of questionnaires based on the employees<br \/>\nfields of work. For this reason one employee is associated with one or more questionnaires, and<br \/>\none questionnaire is associated with many employees.<\/p>\n<p>The managers create the questionnaires, which is why the manager class are related to the<br \/>\nquestionnaire class. The managers are not a defining property of the questionnaire objects and<br \/>\nvice versa. For this reason the relation is an association structure, and not an aggregation<br \/>\nstructure. One manager can be associated with zero or more questionnaires, while one questionnaire is associated with at least one manager.<br \/>\nThe managers manage the employees which is why they are related. Like the manager and<br \/>\nquestionnaire relation, the managers are not a defining property for the employees, which is<br \/>\nwhy the relation is an association structure. One manager can manage zero or more employees,<br \/>\nand one employee can have zero or more managers.<br \/>\nThis results in the class diagram shown in figure 4.3.<\/p>\n<p><img loading=\"lazy\" width=\"651\" height=\"751\" class=\"wp-image-1869\" src=\"https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-7.png\" srcset=\"https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-7.png 651w, https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-7-260x300.png 260w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><br \/>\nFigure 4.3. Class diagram for the problem domain<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Structure After having established the classes in the system, the structure will now be defined with the use of a class diagram. Theory The purpose of the class diagram is to describe structural relations between objects and classes in a problem domain (Lars Mathiassen, 2000, p. 71). The structural relations are different for the classes<a class=\"moretag\" href=\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/\"><span class=\"screen-reader-text\">L\u00e6s mere omClass diagram<\/span>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1725,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Class diagram - HHX opgaver og notater<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/\" \/>\n<meta property=\"og:locale\" content=\"da_DK\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Class diagram - HHX opgaver og notater\" \/>\n<meta property=\"og:description\" content=\"Structure After having established the classes in the system, the structure will now be defined with the use of a class diagram. Theory The purpose of the class diagram is to describe structural relations between objects and classes in a problem domain (Lars Mathiassen, 2000, p. 71). The structural relations are different for the classesL\u00e6s mere omClass diagram[...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/\" \/>\n<meta property=\"og:site_name\" content=\"HHX opgaver og notater\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-16T10:02:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-6.png\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:label1\" content=\"Estimeret l\u00e6setid\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutter\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/rentabilitet.dk\/opgaver\/#website\",\"url\":\"https:\/\/rentabilitet.dk\/opgaver\/\",\"name\":\"HHX opgaver og notater\",\"description\":\"F\\u00e5 adgang til 12-tals opgaver samt notater fra forhenv\\u00e6rende hhx elever. Helt gratis.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/rentabilitet.dk\/opgaver\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"da-DK\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/#primaryimage\",\"inLanguage\":\"da-DK\",\"url\":\"https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-6.png\",\"contentUrl\":\"https:\/\/rentabilitet.dk\/opgaver\/wp-content\/uploads\/2020\/11\/word-image-6.png\",\"width\":477,\"height\":163},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/#webpage\",\"url\":\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/\",\"name\":\"Class diagram - HHX opgaver og notater\",\"isPartOf\":{\"@id\":\"https:\/\/rentabilitet.dk\/opgaver\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/#primaryimage\"},\"datePublished\":\"2020-11-16T10:02:48+00:00\",\"dateModified\":\"2020-11-16T10:02:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/#breadcrumb\"},\"inLanguage\":\"da-DK\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/class-diagram\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Hjem\",\"item\":\"https:\/\/rentabilitet.dk\/opgaver\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Diverse eksamensopgaver\",\"item\":\"https:\/\/rentabilitet.dk\/opgaver\/diverse-eksamensopgaver\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Class diagram\"}]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/pages\/1867"}],"collection":[{"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/comments?post=1867"}],"version-history":[{"count":1,"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/pages\/1867\/revisions"}],"predecessor-version":[{"id":1870,"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/pages\/1867\/revisions\/1870"}],"up":[{"embeddable":true,"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/pages\/1725"}],"wp:attachment":[{"href":"https:\/\/rentabilitet.dk\/opgaver\/wp-json\/wp\/v2\/media?parent=1867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}