1 Course Overview Part II Domain Modelling Techniques Chapter 4: The Existence-Dependency Graph (Class Diagram) Chapter 5: Object Interaction Chapter 6: Object and System Behaviour (FSMs) Chapter 7: Attributes & constraints Chapter 8: Inheritance ex-Cursus: Domain Modelling Patterns Monique Snoeck
2 Patterns & antipatterns Patterns are methods and techniques developed over a period of many years that have been accumulated into expert knowledge and reusable templates (‘old hat’ to seasoned professionals and domain experts) Design Patterns address the problem of designing a software solution Analysis Patterns address conceptual modelling Proven optimal solutions to any recurring design problem in a form of reusable design template. Likewise the term anti-pattern refers to common mistakes in addressing the known problems in architecting process. Monique Snoeck
3 Origin: Christopher Alexander Roots in Alexander’s work on urban design and building architecture The Timeless Way of Building A Pattern Language “Each pattern describes a problem that occurs over and over again in our environment and then describes the core of the solution to that problem in such a way that you can use this solution a million times over without ever doing it the same way twice.” Monique Snoeck
4 Patterns are… Recurring solutions to common problems of design Practical/concrete solutions to real world problems BUT every problem is context specific a good pattern pays attention to a description of the contextual factors a good patterns explains how& why a solution is a ‘best-fit’ for the given set of concerns/trade-offs (cfr. "forces" & "rationale") a good pattern usually identifies a number of "variation points" Description of context, forces, solution and rationale offers a shared vocabulary for problem-solving discussions an effective means of (re)using, sharing and building upon existing wisdom/experience/expertise Monique Snoeck
5 Coplien format 1. Problem 2. Context 3. Forces 4. Solution 5. Resulting Context 6. Rationale Monique Snoeck
6 Domain Modelling Patterns 1. Association Patterns 2. Role Patterns 3. Generalisation / specialisation anti-pattern 4. Object Type pattern Monique Snoeck
1 Domain Modelling Patterns (ex-Cursus) 1. Association Patterns Single association Nested associations "Connect to the lowest" Three party pattern Monique Snoeck
2 Association Patterns Single Association Unary Binary See Chapter 4 N-ary Monique Snoeck
3 Unary, Binary, Multiple Unary: always reify 1 1 B A Bus.Concept A 0..1 BusinessConcept 0..* as_B as_A B Ass.Concept association 0..1 0..* Example Organisational Main 1 1 0..1 SubDept Main Unit Org.Unit part_of 0..* SubDept as_Subdepartment PartOf As_Main Dept. 0..1 Relation 0..* Monique Snoeck
4 Unary, Binary, Multiple Bus.Concept1 Multiple: Always reify Bus.Concept2 Bus.Concept 3 Bus.Concept4 Bus.Concept2 Bus.Concept 3 Bus.Concept4 Bus.Concept1 1 1 1 1 N-ary_Assoc N-ary association Monique Snoeck
5 Unary, Binary, Multiple Multiple: example Course Room Person Room Person Course 1 1 1 Lecture N-ary association Monique Snoeck
6 Unary, Binary, Multiple Binary: it depends For binary associations, a more in-depth analysis is required Benefit ! more in-depth analysis/elicitation of the business rules PEC Course Student BusConcept1 1 1 1 1 0..* 0..* Course 0..* 1..1 Bus.Concept2 Registration Responsibility The association The two business expresses existence concepts are not existent dependency dependent Monique Snoeck
7 Unary, Binary, Multiple Binary: it depends [0..*] [1..*] COURSE many to many ==> reification COURSE composed of MODULE part of [1..1] [1..*] ED ==> no reification ORDER ORDER composed of LINE part of [0..1] [0..*] item can exist without the parcel? PARCEL ITEM composed of part_of ==> no ED ==> reification Monique Snoeck
1 Domain Modelling Patterns (ex-Cursus) 1. Association Patterns 2. Role Patterns 3. Generalisation / specialisation anti-pattern 4. Object Type pattern Monique Snoeck
2 Domain Modelling Patterns (ex-Cursus) 1. Association Patterns Single association Nested associations "Connect to the lowest" Three party pattern Monique Snoeck
3 Nesting Associations The existence of an association depends on the existence of another association. Example: Association 1: A Supplier supplies Products Association 2: A Person orders a Product from a Supplier For Association 2 to exist, Association 1 needs to exist first: one can only order a product from a supplier that is supplied by that supplier. Monique Snoeck
4 Nesting Associations Concept 2 Concept3 Concept1 Concept2 1 1 1 1 2 1 0..* 0..* 0..* 0..* Association2 Association1 Concept1 Concept2 3 1 1 0..* 0..* Association1 Concept3 Binary association 1 1 nested in another 0..* association 0..* Association2 Monique Snoeck
5 Nesting Associations Customer 1 Concept 3 0..* Product Basket Supplier Product 1 1 1 1 2 1 0..* 0..* 0..* 0..* OrderedProduct SuppliedProduct Supplier Product Customer 3 1 1 1 0..* 0..* 0..* Basket Supplied Product Binary association 1 1 nested in another association 0..* 0..* OrderedProduct Monique Snoeck
6 Nesting Associations Example 2 Account Person Account Person 1 1 1 1 1 0..* 2 0..* 0..* 0..* Delegation AccHoldership received from Account Person 3 1 1 1 0..* 0..* AccHoldership Binary association 1 nested in another 0..* 0..* association Delegation Monique Snoeck
7 Domain Modelling Patterns (ex-Cursus) 1. Association Patterns Single association Nested associations "Connect to the lowest" Three party pattern Monique Snoeck
8 "Connect to the lowest" pattern Situation: You have a model You have a new concept to add to this model There are several concepts in the model, the to-be-added concept can be associated with Problem Which association to choose? Course Program 1 1 Course Individual 1 0..* Booking Study Program CourseUse 0..* 0..* Monique Snoeck
9 "Connect to the lowest" principle Solution Connect to the "most existence dependent" business concept Rationale By connecting to the "lowest object" (CourseUsage), one can navigate to the masters (Couse, Program) One connection gives all required information Course Program 1 1 Course Individual 1 0..* Booking Study Program 0..* CourseUse 0..* 0..* 1 Monique Snoeck
10 Connect to the lowest Account Person ??? Person 1 1 1 1 1 2 0..* 0..* 0..* 0..* AccHoldership Delegation Account Person Connect “Delegation” to 3 “lowest” to Account 1 1 1 Holder 0..* 0..* AccHoldership Result = association 1 nested in another 0..* 0..* association Delegation Monique Snoeck
11 Connect to the lowest Yet another example Project Project Employee Employee Team- Team- membership membership Leadership Leadership Monique Snoeck
12 Connect to the lowest Caveat ! this only works when the "lowest" business objects exist at the moment you will create the association the association cannot continue to exist after ending the life of the "lowest" object Example 1 1 Paper University Person 1 1 0..* Contract Authorship 0..* 0..* 0..1 Authorship cannot be nested into contract, because a person continues to be author, even after ending the contract Contract cannot be nested into Authorship, because Authorship is not a prerequisite for contract Monique Snoeck
13 Connect to the lowest Connect to "Lowest" + MPC ensures that you select products that are supplied by the right supplier Connect to "Lowest" allows detailed registration of order fulfiment MPC ensures that you match Received Shipments to BackOrders from the sampe supplier Monique Snoeck
14 Domain Modelling Patterns (ex-Cursus) 1. Association Patterns Single association Nested associations "Connect to the lowest" Three party pattern Monique Snoeck
15 Reading assignment Three Party Pattern Repeated application of "connect to the lowest Person Dept. Task 1 1 1 1 0..* TaskResponsibility Dept.Membership 0..* 0..* 0..* 1 1 TaskAssignment 0..* 0..* Monique Snoeck
1 Domain Modelling Patterns (ex-Cursus) 1. Association Patterns 2. Role Patterns Single role type pattern Separate fixed role type pattern Separate changeable role type pattern Monique Snoeck
2 Single role type pattern Concept1 Concept2 Single_Concept Concept3 … ConceptN Monique Snoeck
3 Domain Modelling Patterns (ex-Cursus) 1. Association Patterns 2. Role Patterns Single role type pattern Separate fixed role type pattern Separate changeable role type pattern Monique Snoeck
Recommend
More recommend