30
INTEC Department of Information Technology http://www.intec.ugent.be Static Object Static Object Modeling Modeling David Matthys – Assistant, GH- SEL

INTEC Department of Information Technology Static Object Modeling David Matthys – Assistant, GH-SEL

Embed Size (px)

Citation preview

INTECDepartment of Information Technologyhttp://www.intec.ugent.be

Static Object ModelingStatic Object Modeling

David Matthys – Assistant, GH-SEL

INTEC - Department of Information Technology

Before we start…Before we start…

A correction related to use cases… when to employ the “includes”-relationship…

Poseidon for UML 4.2 Community Edition alternatives allowed, but not supported

Today’s lecture correlation with UML Distilled? Chapter 3 & 5: class diagrams

Questions?

INTEC - Department of Information Technology

Business analysis (continued)Business analysis (continued)

During the preceding lesson, we explained what a business process is, and how it relates to use cases.

Over the course of it’s execution, a business process touches upon certain “things”.

We identify similar things by choosing the term “business object”.

INTEC - Department of Information Technology

Business objectBusiness object

A business object is a logical concept or a physical entity that holds significant value for an organization.

Examples (in the context of the Department for Kidney Diseases): a medical examination a diet a treatment

Business objects can often be distinguished as nouns in a problem description.

INTEC - Department of Information Technology

ExerciseExercise

Identify relevant business objects for each of the following organizations: a library a university an airline company a football club a nephrology group a car constructor

Report back.

INTEC - Department of Information Technology

Business object – class diagramBusiness object – class diagram

Business objects can be modeled by means of a class diagram: Each object is represented by a class. Relationships are established between objects.

Business objects possess both behaviour and state.

Business objects make up the internal and static structure of the problem domain at hand.

The resulting model is designated as the Static Object Model (SOM).

INTEC - Department of Information Technology

SOM – perspectivesSOM – perspectives

In an implementation view, the diagram reveals the bare implementation. This is where you can apply your knowledge of whatever OO language. (=IMPLEMENTATION)

In a specification outlook, the diagram represents the specification of the interfaces. (=DESIGN)

In a conceptual vision, the diagram shows concepts in the problem domain. This will be the perspective we prefer for this course! (=ANALYSIS)

INTEC - Department of Information Technology

CAUTION!!!CAUTION!!!

Forget what you think you know about class based object orientation and start with a fresh look. Why?

Because while the Static Object Model (SOM) describes classes and their relationships, it does so at a considerably higher level of abstraction than what you have seen until now.

Consider yourselves warned…

INTEC - Department of Information Technology

SOM – UML SOM – UML

UML offers two varieties to draw a SOM: class diagrams object diagrams

Generally, class diagrams are employed, and occasionally, object or instance diagrams help illustrating complex data structures or message passing structures.

We won’t discuss object diagrams further here, and concentrate on class diagrams instead.

INTEC - Department of Information Technology

SOM – drawing upSOM – drawing up

As already mentioned, a SOM uses business objects as building blocks.

Those objects can be further elaborated, in terms of: their operations (responsabilities) their attributes (properties) their relationships with other business objects

(collaborators) Our intention is to put emphasis especially

on business objects as units offering some useful service, instead of business objects merely as containers of data.

INTEC - Department of Information Technology

A good business objectA good business object

INTEC - Department of Information Technology

A bad business objectA bad business object

INTEC - Department of Information Technology

About relationshipsAbout relationships

Relationships enable business objects to achieve a more complex behaviour than each of them would be capable of on its own.

Consequently, relationships will transcend the boundaries of the related classes.

Two principal categories of relationships exist: association generalisation

INTEC - Department of Information Technology

AssociationAssociation

Associations represent structural relations between objects of different classes.

Each end of an association is a role and can have a role name.

Each role indicates the multiplicity of its class.

Associations can be further subdivided into: associations (ordinary) aggregations compositions

INTEC - Department of Information Technology

Association - exampleAssociation - example

INTEC - Department of Information Technology

AggregationAggregation

An aggregation is an association, but a special one: a “part-of” relationship.

A patient is not a part of a nurse (or the other way around)!

The difference between the two is not always clear; different authors have different opinions.

When using it in your diagrams, be sure that you can explain what you actually mean!

INTEC - Department of Information Technology

Aggregation – exampleAggregation – example

INTEC - Department of Information Technology

CompositionComposition

A composition is an aggregation, but with two extra properties: An instance may be a component of only one

owner. If you delete the owner, al owned instances should

also be deleted. Composition is recommended for properties

that have a strong and somewhat exclusive ownership of particular other components.

INTEC - Department of Information Technology

Composition – exampleComposition – example

INTEC - Department of Information Technology

Associations or attributes?Associations or attributes?

Associations do not always hold during entire lifetime of all instances!

Use attributes for small things (boolean, date), and associations for more significant classes, such as customers and orders.

The distinction between a domain object and a value object might prove helpful to you. identity? number of copies?

INTEC - Department of Information Technology

Association classAssociation class

INTEC - Department of Information Technology

Association promoted to a classAssociation promoted to a class

INTEC - Department of Information Technology

Association class or full class?Association class or full class?

An association class allows you to add features like attributes, operations and the like to associations.

Only one instance of an association class can connect any two participating objects.

If more than one link connecting the same pair of objects is a possible situation, you should promote the association to an ordinary class.

Otherwise, use an association class.

INTEC - Department of Information Technology

GeneralizationGeneralization

Generalisation (or specialisation) enables the developer to organise classes in a hierarchical structure based on their similarities and their differences.

The term generalisation refers to the “is-a” relationship between classes.

Anything we say about the supertype about a.o. associations, attributes and operations, also holds for the subtype (conceptually).

INTEC - Department of Information Technology

Generalization – incorrect useGeneralization – incorrect use

INTEC - Department of Information Technology

Generalization – correct useGeneralization – correct use

INTEC - Department of Information Technology

Generalization - classificationGeneralization - classification

Shep is a Border Collie. (1) A Border Collie is a Dog. (2) Dogs are animals. (3) A Border Collie is a Breed. (4) A Dog is a Species. (5)

INTEC - Department of Information Technology

Watch out!Watch out!

The phrase “is-a” can mean different things! Sometimes we mean generalization…

An type (Border Collie) is a subtype of another type (Dog).

Other times, we mean classification! An object (Shep) is an instance of a type (Border

Collie). Generalization is transitive, classification is

not!

INTEC - Department of Information Technology

Hints and tipsHints and tips

Fowler explains class diagrams mainly from a software-technical perspective.

Analysis is rather art and craft than science. The scope of the problem domain largely

determines whether a particular business object belongs to it.

Omit responsabilities and properties when you start. Focus on collaborations instead.

Don’t underestimate the importance of a sound ontology (next slide)!!!

Questions?

INTEC - Department of Information Technology

Building a vocabularyBuilding a vocabulary

Medical examination A patients visits a doctor, who carries out both an

anamnesis and a full investigation. Diet

A diet guides the patient in the adaptation of his eating habits, in order to achieve some predefined objectives. This is typically formulated by means of several instructions.

Treatment A treatment constitutes an action in the context of

nursing the patient, such as the application of a dialysis, or the administration of specific drugs.