Slide03 DomainModel
Slide03 DomainModel
Association Multiplicity Aggregation Composition Building a Domain Model Structuring a Domain Model
&he Domain Model captures the concepts in the domain of the problem' and the relationships bet(een them )t establishes the vocabulary of the problem domain
An object is a thing or concept that can be distinctly identified' e*g* a specific person' organi+ation' machine' or message An object can have values associated (ith it' called ,value- attributes* &he values of the attributes can change' but not their number and names Attributes of an object during requirements elicitation or analysis are not allo(ed to be objects An object during requirements elicitation or analysis does not have methods
6
A person (ho might receive a letter A person suspected in a criminal case A person having a ban/ account &he person the phone bill is sent to An employee of a company using a security access card
7
Associations
Associations are the 0glue1 that holds together an object#oriented system* 2ithout associations' there is only a set of unconnected classes An association models a relationship bet(een objects &he e istence of an association is conditional. all related classes must e ist Similarly' an occurrence of an association can only e ist if the connected objects all e ist
8
An association bet(een objects corresponds to the mathematical concept of a relationship % bet(een the classes ,sets- 3i to (hich the objects i belong &he relationship % is a subset of the cartesian product of the sets 34' 35' 6' 3n &he elements of % are called the occurrences of the relationship or the lin/s of the association &he relationship is said to be true for the objects 6' n if and only if , 4' 5' 6' n- belongs to %
4
'
'
&he sets 34' 35' 6' 3n are called the domain of the relationship and n is its arity &he sets 3i are not necessarily different
9
Association in "M#
An association is represented in UM7 as a line connecting t(o ,or more- classes &he name of the association is placed 0on1 or 0beneath1 the line Optionally' a blac/ triangle indicates ho( to read the association relationship
10
Association Occurrences
&he lin/s of an association can be represented by a table of tuples 8ach lin/ is uniquely identified by the objects it connects together* )n the table' there cannot be any identical tuples
&eaches 9rofessor Course Bruce 9ercolation &heory Bruce 9olyhedral Computation :;rg Object#Oriented Soft(are Development :;rg Soft(are !ault &olerance 7uc 9robabilistic Algorithms
11
Association E$am%les
&he printer "eo' of type 9haser <<=="' made by 3ero ' located in room McConnell >55*** Mr* %ich' business man' <5 years old' living in ?ug' S(it+erland' married (ith Mrs* Dufour' *** Mr* %ich o(ns an account (ith the S(iss Union Ban/ A flight corresponds to an aircraft flying a route on some (ee/day
12
Consider a tuple , 5' *** n-* 2e may as/ if there are any objects 4 in 34 such that , 4' 5' 6' nbelongs to %' and ho( many they are* &heir minimal and ma imum numbers are called the multiplicity ,cardinality- of 3 4 in the association %* card,34 in %- @ ,min' ma card,A, 5' 6'
n
- , 4'
' 6'
- %B13
&he multiplicity ,or cardinality- defines the number of objects (hich are allo(ed to be associated (ith each other in an association Multiplicity is sho(n by annotating the ends of the association line' called the association end &he full form is a range ,or even a set of ranges-' e*g* =**4' 4**4' 4**<' =**C' 4**C' an asteris/ C meaning that the upper limit is unlimited Sometimes short forms are used. 4 for 4**4' 5 for 5**5' etc*' and C for =**C
14
15
Errors *
16
Association +lass
An association class is an association that is also a class An association class has both association and class properties. it connects t(o or more classes' and it also has attributes and sometimes operations 7i/e for all associations' the identity of an occurrence stems from the connected objects* )n UM7' an association class can participate in an association* 2e do not recommend this practice 17
An association class is used (hen an attribute goes (ith the association rather than (ith any of the connected classes 2e (ant to /eep trac/ of the mar/ a student has got for a test &he attribute does not mar/ belong to the student' because a student may ta/e many tests "either does it belong to a test' because many students ta/e the same test
18
An association need not have a name* Usually' role names are more convenient because they avoid the problem of (hich (ay to read the name and they provide names for navigation and code generation
19
%ole names clarify the semantics of an association' especially (hen refle ive As a child' a person has e actly t(o parents* As a parent' a person may have several children*
20
Aggregation &'(
Aggregation is a form of binary association that specifies a (hole#part relationship bet(een an aggregate ,a (hole- and a constituent part &he aggregation relationship is transitive and antisymmetric across all aggregation lin/s' even across those from different aggregation associations )f a is part of b and b is part of c' then a is part of c ,transitivity-* )f a is part of b ,directly or indirectly-' then b cannot be part of a ,antisymmetry21
Aggregation &)(
A part can belong to more than one aggregate' and it may e ist independently of the aggregate Often the aggregate needs the parts' i*e* it is a collection of the parts' but the parts can e ist by themselves (ithout being regarded only as parts 8 ample
A path is an ordered set of segments* A segment can belong to several paths* &he path 0needs1 its segments &he distinction bet(een a plain association and an 22 aggregation is often a matter of taste
Aggregation E$am%les
Aggregation is graphically represented (ith an empty diamond on the association end of the aggregate
23
+om%osition
Composition is a strong form of aggregation* )t has more specific semantics that correspond to physical containment and various notions of o(nership A part may belong ,directly- to only one composite ,at a time-* &he multiplicity of the composite element must therefore be 4 or =**4* &he composite object has responsibility for the disposition of all its parts' i*e* for their creation and destruction
24
Composition is graphically represented (ith a filled diamond on the association end of the composite
25
Composition may also be sho(n by graphical nesting* A nested elementDs role name is (ritten in front of its class name
26
27
Derived Association
28
!ualified Association
29
9hysical objects. car' pen' *** 9eople' organi+ations. cler/' employee' company' *** 9laces. building' room' *** Concepts. trajectory' ledger' flight' ***
Distinguish objects from classes' and roles from classes Suppress the redundant' irrelevant' vague classes 7oo/ at the use casesE
30
9eople hold shares of companiesF there is at most one occurrence of a pair ,company' person9eople purchase shares of companies* 8ach purchase has its o(n date and price in addition to quantity
31
An attribute is an association bet(een a class and a set of values An attribute usually does not have multiple occurrences
8 ample. since some professors teach several courses' course is better made a class' and )s&eacherOf an association bet(een professors and courses
An attribute cannot have attributesF the association class )s&eacherOf bet(een professors and courses could have a term attribute sho(ing (hen the course is given by the professor An association is therefore more fle ible' but donDt overshoot***' e*g* no need to model the date of birth by 32 an association bet(een a person and a date
A pile of plates is made up of plates 8ach plate /eeps its identity' but cannot be used as long as it is in the pile ,the parts cannot be shared&he destruction of the pile leads to the destruction of the plates &he number of plates in a pile varies bet(een +ero and many &he si+e of a pile is an attribute' and not a component of the pile
33
A family is an aggregate object made up of the parents and their children &he relationships father#child' mother#child' brother#sister are plain associations &he contents of a suitcase changes as the user li/esF the relationship bet(een a container and its contents is often an aggregation' rather than a composition association* )s the liquid contents of a bottle really an objectG
34
35
Constraints are used to model requirements' assertions' and invariants that cannot be e pressed by other means' e*g* by multiplicity in associations Constraints are e pressed by te tual annotations' or by using OC7' the Object Constraint 7anguage
36
37
Reification
&he process of ma/ing out of a concept an object or class is called reification' meaning 0ma/ing it an object1 An important consequence of reification is that some entity suddenly gets an identity %eification can be applied to associations and connected classes A reified association has all the properties of a class* 8specially' it can participate in relationships %eification can be used to structure a class model
38
A flight is a reification of 0an aircraft scheduled on some route on some (ee/day1 A person o(ns a car* A title is a reification of this relationship* A title has an identity' it has attributes on its o(n' it can be transferred &he result of physical composition is naturally an object. e*g* a car is composed of a motor' (heels' etc %eification is often applied to non physical composition. e*g* a department (ith its personnel' buildings' budget' etc
39
40
8 am contains pairs of sets of students and tests belonging to the association &a/es 8 am has the attribute duration An e am is held in a room' (hich sho(s that a composition may participate in an association A test e amines some course' (hich sho(s that a component class can participate in an association
41
&he complete domain model is the union of all the class diagrams' together (ith the related constraints &(o class bo es (ith the same name denote the same class %eification and composition provide means for levelling the diagrams 9ac/ages can be used for defining name spaces' and therefore controlling name scopes
42
/tructuring E$am%le
43
Brainstorm a list of candidate classes and relationships )ncrementally produce the Domain Model' loo/ing for.
Henerali+ations' modelling I/ind ofI and Iis aI relationships Aggregations' modelling Ipart ofI and Ihas aI relationships Associations Derived associations Attributes of classes' Attributes of associations Multiplicities of associations Constraints' to be recorded in OC7 ,and$or in te t44
8ach user has a ma imum number of boo/s that are allo(ed to be on loan at any one time* &he limit is dependent on the category of the member' e*g* department heads can ta/e out as many as 4== boo/s' (here research assistants are limited to 4K boo/s* Often' a certain category of boo/ a different loan period for each category of member' e*g* professors are allo(ed to borro( a standard boo/ for L months' (hereas graduate students are allo(ed only > months* Different categories of boo/s have different loan periods ,e*g*' lecturers may borro( a standard boo/ for > months' but can only loan a periodical for 4 month-* )t might even not be possible' for a certain category of member' to borro( certain boo/s ,e*g* undergraduate students cannot borro( reference boo/s-* Boo/s that are on reserve are not available for loan*
47