Docsity

object oriented programming notes, Lecture notes of Object Oriented Programming

Toggle sidebar
bg1
DOMAIN MODELLING Page 1 of 18 BY: BENSON M. IRERI
Domain Model and Domain Modeling
The quintessential object - oriented analysis step is the decomposition of a domain into
noteworthy concepts or objects.
A domain model is a visual representation of conceptual classes or real - situation objects in a
domain.
Domain models have also been called conceptual models, domain object
models, and analysis object models.
Applying UML notation, a domain model is illustrated with a set of class diagrams in which
no operations (method signatures) are defined. It provides a conceptual perspective. lt may
show:
• domain objects or conceptual classes
• associations between conceptual classes
• attributes of conceptual classes
Definition: Why Call a Domain Model a "Visual Dictionary"?
Please reflect on Figure for a moment. See how it visualizes and relates words or
concepts in the domain. It also shows an abstraction of the conceptual classes, because
there are many other things one could communicate about registers, sales, and so forth.
Definition; Is a Domain Model a Picture of Software Business Objects?
A UP Domain Model, as shown in Figure, is a visualization of things in a real - situation
domain of interest, not of software objects such as Java or C# classes, or software objects
with responsibilities. Therefore, the following elements are not suitable in a domain model:
• Software artifacts, such as a window or a database, unless the domain being modelled
is of software concepts, such as a model of graphical user interfaces.
• Responsibilities or methods.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download object oriented programming notes and more Lecture notes Object Oriented Programming in PDF only on Docsity!

Domain Model and Domain Modeling

The quintessential object - oriented analysis step is the decomposition of a domain into noteworthy concepts or objects. A domain model is a visual representation of conceptual classes or real - situation objects in a domain. Domain models have also been called conceptual models , domain object models , and analysis object models****. Applying UML notation, a domain model is illustrated with a set of class diagrams in which no operations (method signatures) are defined. It provides a conceptual perspective. lt may show:

  • domain objects or conceptual classes
  • associations between conceptual classes
  • attributes of conceptual classes Definition: Why Call a Domain Model a "Visual Dictionary"? Please reflect on Figure for a moment. See how it visualizes and relates words or concepts in the domain. It also shows an abstraction of the conceptual classes, because there are many other things one could communicate about registers, sales, and so forth. Definition; Is a Domain Model a Picture of Software Business Objects? A UP Domain Model, as shown in Figure, is a visualization of things in a real - situation domain of interest, not of software objects such as Java or C# classes, or software objects with responsibilities. Therefore, the following elements are not suitable in a domain model:
  • Software artifacts, such as a window or a database, unless the domain being modelled is of software concepts, such as a model of graphical user interfaces.
  • Responsibilities or methods.

Domain modelling helps us to identify the relevant concepts and ideas of a domain. Domain modelling is done during object-oriented analysis. “Curtis’law: […] Good designs require deep application knowledge.” The domain model is created during object-oriented analysis to decompose the domain into concepts or objects in the real world. The model should identify the set of conceptual classes (The domain model is iteratively completed.). It is the basis for the design of the software. The domain model is also called conceptual model, domain object model or analysis object model.

Conceptual Classes

Definition: What are Conceptual Classes? The domain model illustrates conceptual classes or vocabulary in the domain. Informally, a conceptual class is an idea, thing, or object. More formally, a conceptual class may be considered in terms of its symbol, intension, and extension.

  • Symbol - words or images representing a conceptual class.
  • Intension - the definition of a conceptual class.

To visualize domain models the UML class diagram notation is used. However, no operations are defined in domain models • Only domain objects and conceptual classes, associations between them, attributes of conceptual classes are defined. The result is a conceptual perspective model. Visualizing Domain Models Exemplified (By means of a basic course management system.) Statements about a Course Management System During a semester a lecturer reads one or more lectures, Sometimes the lecturer is on leave to focus on doing research, in this case (s)he does not give a lecture A student usually attends one or more lectures, unless (s)he has something better to do. During the semester there will be several exercises which are meant to be solved by small study groups. Each student is assigned to one particular study group for the whole semester. A study group consists of two to three students. After submission of a solution by a study group it is graded by a tutor. Solution A class describes a set of objects with the same semantics, properties and behaviour. When used for domain modelling, it is a visualization of a real-world concept.

  • During a semester a lecturer reads one or more lectures
  • A student usually attends one or more lectures, ...
  • During the semester there will be several exercises...
  • Each student is assigned to one particular study group for the whole semester
  • ... it is graded by a tutor

Attributes are logical data values of an object. It is useful to identify those attributes of conceptual classes that are needed to satisfy the information requirements of the current scenarios under development. ... after submitting a solution, it is graded by a tutor The bonus is a relative bonus that reflects the relative number of exercise points gained during the semester

The multiplicity defines how many instances of a class A can be associated with one instance of a class B at any particular moment. (e.g., * ≙ zero or more; 1..10 between 1 and 10; 1,2 one or two) A student usually attends one or more lectures, unless (s)he has something better to do

  • A study group consists of two to three students

Two classes can have multiple associations. A student usually attends one or more lectures, unless the student has something better to do

  • A study group consists of two to three students; after submitting a solution it is graded by a tutor who is also a student A preliminary domain model for a course management system.

Identify noun phrases to find the conceptual classes (linguistic analysis) Identify the nouns and noun phrases in textual descriptions of a domain and consider them as candidate conceptual classes or attributes

  • A mechanical noun-to-class mapping isn’t possible; words in natural languages are ambiguous; i.e. the same noun can mean multiple things and multiple nouns can actually mean the same thing “Use Cases” are also an excellent source for identifying conceptual classes. Identify noun phrases to find the conceptual classes.

Identify noun phrases to find the conceptual classes.

“ Facts ”: • Identified candidate conceptual classes: ... Receipt, .…

  • A receipt is just a report of a sale and a payment...
  • Should Receipt be in the domain model?
  • Well, it depends….
  • … if we just consider the current scenario then receipt should not be part of the domain model; a receipt is just a report
  • … if we also consider how to handle returns then a receipt represents an important concept on its own
  • How about legal restrictions...?
  • A description class contains information that describes something else Examples:
    • a product description records the price, picture and text of an item
  • a flight description contains information about the flight (number) and the source and target destinations
  • A description class should be added to the domain model when:
  • There needs to be a description about an item or service, independent of the current existence of any examples of those items or services
  • Deleting instances of things, they describe results in a loss of information that needs to be maintained, but was incorrectly associated with the deleted thing
  • It reduces redundant or duplicated information When should I model something as an attribute or a class?
  • Rule of Thumb : If we do not think of some conceptual class X as a number, date or text in the real world, X is probably a conceptual class, not an attribute.
  • Should destination be an attribute of flight, or a conceptual class airport?
  • A destination airport is a building at a specific place, it is not just a number or some text. Hence, it should be a conceptual class.
  • How about the name of the airport? Rule of Thumb: Include associations in the domain model for which knowledge of the relationship needs to be preserved for some duration. Because we are working on the conceptual model; we are not modelling associations at the software level. When should I add an association to the domain model? When an association is among the common associations list:
  • A is a transaction related to another transaction B
  • A is a line item of a transaction B
  • A is a product or service for a transaction B
  • A is a role related to a transaction B
  • A is physical or logical part of B E.g. the relation between a Sale and a SalesLineItem needs to be remembered. However, it is not necessary to store the relation between a Cashier and a ProductDescription that he looks up. Name an association based on a ClassName-VerbPhrase-ClassName format. The verb phrase creates a sequence that is readable and meaningful. Good examples:
  • Player Is-on Square!
  • Sale Paid-by CashPayment Bad examples:
  • Sale Uses CashPayment (Uses is usually generic and doesn’t tell us anything.)
  • Player Has Square (Has is usually generic and doesn’t tell us anything.)
    • The attributes in a domain model should preferably be “primitive” data types (w.r.t. the domain!).
    • • Very common data types include: o Boolean, Date,

Excerpt of the Domain Model for the POS System The domain model serves as a source of inspiration for the design model.

By using the domain model as a direct inspiration for software classes the representational gap between the domain concepts and the program is (relatively) small. By using the domain model as a direct inspiration for software classes the representational gap between the domain concepts and the program is (relatively) small. The goal of this lecture is to enable you to systematically carry out small(er) software projects that produce well-designed software.

  • Domain Modelling is useful to understand the ideas and concepts of the domain and their interrelationships
  • A Domain Model is usually created at the beginning of a project and is a basis for the design model
  • A Domain Model is created using a subset of the UML class diagram notation