domain model
TRANSCRIPT
Domain Model
Dzenan Ridjanovic
2009-03-08
Domain Model
Domain model is a semantic network of concepts and their relationships in a certain domain.
Example of a domain: Education.Example of a model: PersonalLibrary.Example of concepts: Book, Person.Example of a relationship: a person may borrow several books; a book may be lent to a person.
Model Concept
A concept often represents an organization, a product, a service, a person, a transaction, a thing, an event, ...
A concept may have many entities in a real world.
Book is a concept. There may be many books that share the same attributes.
Concept Descriptors
A concept has structure (properties, neighbors) and behavior (methods).
A concept may have an identifier.
An identifier gives a unique identity to each entity of the same concept.
Book Concept
Book properties: title, author.
Book neighbor: person.
Book identifier: title.
Book methods: isCataloged, isAvailable, checkOutTo, checkIn, catalog, discard.
Person Concept
Person properties: firstName, lastName, maxNumberOfBooks.
Person neighbor: books.
Person identifier: firstName, lastName.
Person methods: isMember, isWithoutBooks, register, unregister.
Concept Property
A property is a characteristic of its concept.
A property of an entity may be null.
A property of an entity usually carries a single value.
A property value comes from a type of possible values.
Book Property
Book property: title.
The title property is a characteristic of the Book concept.
A book must have a title.
A title of a book carries a text value.
A title text comes from String values.
Person Property
Person property: maxNumberOfBooks.
A maxNumberOfBooks is a characteristic of the Person concept.
A person may have a default value for maxNumberOfBooks.
A maxNumberOfBooks of a person carries an integer value.
Concept Neighbor
A neighbor is a relationship characteristic of its concept.
A neighbor of an entity usually references a single entity (parent neighbor) or a collection of entities (child neighbor).
A parent neighbor of an entity may be optional (null).
A child neighbor may be an empty collection of entities.
Book Neighbor
Book neighbor: person.
The person neighbor is a relationship characteristic of the Book concept.
A book may not be related to a person and in that case is available.
A book that references a person is not available.
Person Neighbor
Person neighbor: books.
The books neighbor is a relationship characteristic of the Person concept.
A person may have an empty collection of books.
Entry Concepts
Some concepts in a model are declared as entry points to the model.
Non-entry concepts are reachable only from entry concepts by following neighbors.
Concepts with only child neighbors are good candidates for entry points.
Personal Library Entries
Person
Book
Personal Library Model
Eclipse Project
Eclipse project in the modelibra space at Assembla: modelibra.beginner
src: source code
test: test code
mm: model files
Java Packages
One package for model.
One package for concepts (for a small model).
One package per concept (for larger models).
Java Classes
One class for model.
Two classes for each concept: Concept, Concepts.
Model Class
Create entry points in the model's constructor.
Concept Class
First do Concept classes for entry points.
Model parent property, properties for parent concepts, properties for child concepts.
Create child entities in the concepts's constructor.
Private set methods (or not at all) for setting parents or children.
Public attach and detach methods for relationships.
Concepts Class
Add an entity.
Get an entity based on its identifier.
Select and order methods.