Bring ideas to life
VIA University College
  Analysis - Domain Models
   SWE1
VIA University College      Domain Models - Ib Havn, iha@via.dk   2019-03-12   1
ICT-Engineering
Develop Domain Models to understand the
                              problem
We MUST understand the problem – don’t think in software/implementation!!
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   2
ICT-Engineering
Domain Model
A visual guide over a specific problem area – typical illustrated as a Class
Diagrams
– Important Problem Domain concepts (classes, attributes)
– Relationships between these concepts
Used for
– Common understanding between customer/end user and programmer of
   the problem
– Communication with stakeholders
– Finding problems in the understanding
– Finding improvements
Artefacts: UML Diagrams and descriptions
VIA University College   Domain Models - Ib Havn, iha@via.dk     2019-03-12    3
ICT-Engineering
Domain Model Artefacts
Static views (show what is possible)                           Dynamic views (shows a given situation)
  Classes and relationships                                     Actors and System with relations
  – Shows static structure of the                               – Shows a dynamic behaviour in a
     systems concepts                                              given Use Case scenario
                                                                Behaviour Diagrams:
  Structure Diagrams:                                           – Sequence/activity/communication
  – Class diagrams                                                 diagrams
VIA University College   Domain Models - Ib Havn, iha@via.dk                       2019-03-12        4
ICT-Engineering
Domain Model
Artefacts
Marked UML diagrams are typical
Domain Model artifacts
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   5
ICT-Engineering
How to come from Requirements to
Domain Model
                                                                               Delimits
                                                           Only analyse what the
                        Functional                         req. is talking about           Analysis
                       Requirements                        – And do only what’s            (Domain
                     (Use Case Model,                         needed to fulfil the        Model/Class
                          SSDs)                                                            Diagram)
                                                              requirements
                    Activities                                                Refines     Concepts
                    Behaviour                                                             Relationships
                    Rules                                  Missing/wrong req. will        Scenarios
                    Actors                                 often be found during
                                                           this process
                    Dynamic
VIA University College                  Domain Models - Ib Havn, iha@via.dk                  2019-03-12   6
ICT-Engineering
How to come from Requirements to
Domain Model
Typically an interactive process
– One or two requirements/Use Cases are taken out for analysis in each
   iteration/sprint in UP/SCRUM
– The Domain Model will be build up step by step in sprints
A Sequence/Communication diagram is often needed to really understand the
Domain Model in a given Use Case scenario
– Shows a given situation/scenario/snapshot of the system at a given time
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   7
ICT-Engineering
How to come from Requirements to
Domain Model
Often you will need to be an “expert” in the customers problem domain
– Our role is to help the customer to earn money
– Give them ideas
– Raise questions to the customers requirements
In education programs
– We work in small well-known problem domains like Math, Recipe systems etc.
– In real life you will meet problem domains you don’t know anything about
Requirements and Domain Models helps us to understand what we need to know!
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   8
ICT-Engineering
How to come from Requirements to
Domain Model
Think like a Map-Maker
– Who is the target group?
– Use words/vocabulary already known in the
   domain
– Remember: Not too many details – only what
   is needed to understand the problem
– Don’t add things that doesn't exist in the
   domain
   – Software things (DBs, Patterns, computers
– Use experts
   – End-users, books, consultants, articles etc.
– Always discuss your Domain Model with
   domain experts and customer!
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   9
ICT-Engineering
How to find Conceptual Classes
Step – by step
Step 1
Find concept candidates
– Mark up all Nouns and Verbs in requirements/Use Case scenarios with two
   different colours
– Reuse existing models
– Create a category list (list of candidates) [Larman, 2005] p. 139
– Brainstorm – remember no debate when brainstorming
Step 2
Remove duplicates
   – Things have often different names – ask the domain which to use and be
       consistent
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12     10
ICT-Engineering
How to find Conceptual Classes
Step – by step
Step 2 – continued
Classes vs. attributes
Ex. Two concept candidates is found Item and Price
         Is it two separate classes?
         Is Price an attribute to an Item?
         Or maybe we need for Price as a separate class and a
         relation-ship? Can an Item have more Prices
VIA University College     Domain Models - Ib Havn, iha@via.dk   2019-03-12   11
ICT-Engineering
How to find Conceptual Classes
Step – by step
Step 2 – continued
Find Report Classes
                         Report Class!
                         It is not needed in the
                         implementation, the report
                         can be assembled and printed
                         via the enrolled relation-ship
VIA University College         Domain Models - Ib Havn, iha@via.dk   2019-03-12   12
ICT-Engineering
How to find Conceptual Classes
Step – by step
Step 2 – continued
Find Description Classes
                         Description!
                         Is this the same for all
                         cars of same model?
                         (Duplication!!)
                                                                       Description Class!
                                                                       If it is the same for all cars of
                                                                       same model – then it is a
But is it true in all cases?                                           separate class/concept and
• Dealer of new cars                                                   duplication is avoided!
• Dealer of second hand cars
VIA University College           Domain Models - Ib Havn, iha@via.dk      2019-03-12                13
ICT-Engineering
How to find Conceptual Classes
Step – by step
Step 2 – continued
Look at Actors
– Are they classes? – sometimes, sometimes not
         Must the system store information about them?
                                                                    Nurse
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   14
ICT-Engineering
Associations/Relation-ships in Domain
Models
Association in Domain Model
– A named relation between two classes
– Should give meaning and be important
– Increases understanding
Comes from
– Requirements/Use Case Scenarios
  – Verbs are candidates
– Common association list
– Are there things that must be remembered over time?
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   15
ICT-Engineering
Associations/Relation-ships in Domain
Models
Guidelines
– Use meaningful names – not has/contains/consist of etc.
– Show only multiplicity if needed for understanding
                                                               Are the multiplicities
                                                               necessary? Or is it obvious?
                                                               Is it right that a Car can have
                                                               no owners?
VIA University College   Domain Models - Ib Havn, iha@via.dk     2019-03-12               16
ICT-Engineering
   Associations/Relation-ships in Domain
   Models
   Derived associations
   – Something that can be found or calculated
   – Are shown if they get better
      readability/understanding
   Association Classes
                                                                       The works at association can
                                                                       be derived from the Teacher –
                                                                       Contract – University
                                                                       associations
This is a better solution than
the derived association
   VIA University College        Domain Models - Ib Havn, iha@via.dk   2019-03-12            17
   ICT-Engineering
Associations/Relation-ships in Domain
Models
Reflexive associations
How would it be looking if we also wants to
model marrieds?
Can you draw up a communication diagram
showing your family two generations back?
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   18
ICT-Engineering
Attributes in Domain Models
The information/data that is needed to support the requirements
– focus on attributes that are Odd, Strange, Advanced – not the obvious ones
Candidates:
– Look at what is coming in- and out from a system
– What data is handled by the system?
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12      19
ICT-Engineering
Attributes in Domain Models
Data type classes
Ex: A Person has an address
What is an address?
What if a Person has more than one address?
                                                                                      Data type class
                                                                     This is better
           This is chaotic!!
VIA University College         Domain Models - Ib Havn, iha@via.dk                         2019-03-12   20
ICT-Engineering
Attributes in Domain Models
Painted types
Primitive types that we apply a lot of rules to
Ex: A phone no
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12   21
ICT-Engineering
Attributes in Domain Models
Derived Attributes
Attributes that does not exist as attributes, but will be calculated when needed
totalPrice will be calculated by the Receipt class via the association
A Person has a date of birth, so we can always find the
persons age without having a real attribute for it – same with
fullName
Derived attributes are show to make the diagram more clear and understandable
VIA University College   Domain Models - Ib Havn, iha@via.dk     2019-03-12        22
ICT-Engineering
Attributes in Domain Models
History
Often it is needed to record history data, but is often
forgotten by the customer
Watch for historical data – and remember it makes
things more complicated!
                                                                     The customer wants to show prices over time
Ex: What if Item prices change over time?
   This solution gives redundancy, and can’t really
   keep track of prices over time
VIA University College         Domain Models - Ib Havn, iha@via.dk               2019-03-12              23
ICT-Engineering
Exercise
Look at this Dice game that has these simple “requirements”/rules:
Requirements:
   The dice are rolled and the result is presented; if the sum is seven the player
   wins!
Find the conceptual classes, attributes and their relation-ships and create a
Domain Model
First on paper, and then in Astah
VIA University College   Domain Models - Ib Havn, iha@via.dk   2019-03-12        24
ICT-Engineering
Is it worth the effort to design software well?
Ask your-self this simple question:
“Do I want my software to be a success?”
                                                               https://martinfowler.com/bliki/DesignStaminaHypothesis.html
VIA University College   Domain Models - Ib Havn, iha@via.dk                                2019-03-12                 25
ICT-Engineering