advanced object-oriented analysis...

27
Softwaretechnologie II, © Prof. Uwe Aßmann 1 Advanced Object-Oriented Analysis Concepts Prof. Dr. U. Aßmann Technische Universität Dresden Institut für Software- und Multimediatechnik Gruppe Softwaretechnologie http://www-st.inf.tu-dresden.de Version 06-0.8, June 12, 2006

Upload: phungquynh

Post on 23-Apr-2018

218 views

Category:

Documents


2 download

TRANSCRIPT

Softwaretechnologie II, © Prof. Uwe Aßmann 1

Advanced Object-Oriented Analysis Concepts

Prof. Dr. U. Aßmann

Technische Universität Dresden

Institut für Software- und Multimediatechnik

Gruppe Softwaretechnologie

http://www-st.inf.tu-dresden.de

Version 06-0.8, June 12, 2006

Prof. U. Aßmann, Softwaretechnologie II 22

Contents

► Different kinds of classes and their relationships (UML class profiles)

► Facet-based classifications (powertypes)► The UML metamodel

Prof. U. Aßmann, Softwaretechnologie II 3

Obligatory Reading

► Ghezzi Chap 4.2, 4.6► Pfleeger 12.4 Software Reusability► [ if you have it: Maciaczek 5.4]

Prof. U. Aßmann, Softwaretechnologie II 4

Literature

► I. Mathiassen, A. Munk-Madsen, P. Axel Nielsen, J. Stage. Objektorienterad analys och design. Studentliteratur.

► Ken Lunn. Software Development with UML. Palgrave-Macmillan.► UML 2.0 report. Object Management Group (OMG).

http://www.omg.org/uml► I. Jacobsen, G. Booch, J. Rumbaugh. The Unified Software

Development Process. Addison-Wesley. The united process from the “3 amigos”. Guiding through the OOD, from OOA to OOP.

► L. A. Maciaszek. Requirements Analysis and System Design. Addison-Wesley.

Softwaretechnologie II, © Prof. Uwe Aßmann 5

Common Class Patterns

Prof. U. Aßmann, Softwaretechnologie II 6

How To Use Class Classifications

► UML allows for annotations of classes with stereotypes■ Classes can be “marked-up”, i.e., annotated with more semantics■ If the engineers knows classifications of classes, he can convey much

more semantic in his models

► Learn the classes, use them as stereotypes■ UML 2.0 superstructure, Appendix B contains a huge set of standard

stereotypes

► User can define stereotypes and collect them in UML profiles

Prof. U. Aßmann, Softwaretechnologie II 7

Types Of Classes (Bahrami Profile)

► Concept class ■ A concept is a notion on that many people agree in a domain (an

ontology is a collection of concepts)■ Frequently used in a domain model

► Events class ■ Event that happens over time

► Organization class■ Captures knowledge about an organization

► People class■ Captures knowledge about people (actors)

► Places class■ Captures knowledge about locations

<<concept>>

<<event>>

<<organization>>

<<people>>

<<place>>

Prof. U. Aßmann, Softwaretechnologie II 8

Types of Classes (Rumbaugh Profile)

► Physical class (e.g., Boat)► Business class (e.g., Bill)► Logical class (e.g., Timetable)► Application class (e.g., BillingTransaction)► Computer class (e.g., Set)► Behavioral class (e.g., Cancellation)

<<physical>>

<<business>>

<<logical>>

<<application>>

<<computer>>

<<behavior>>

Prof. U. Aßmann, Softwaretechnologie II 9

BCE/BCED Profile

► Boundary classes:■ Represent an interface item that talks with the user■ May persist beyond a run

► Control class:■ Controls the execution of a process, workflow, or business rules■ Does not persist

► Entity class:■ Describes persistent knowledge. Caches a persistent object from a

database

► Database class■ Adapter class for the database■ Often, Entity and Database classes are unified

► BCED is linked with the 4-tier architecture

<<boundary>>

<<control>>

<<entity>>

<<database>>

Softwaretechnologie II, © Prof. Uwe Aßmann 10

Facet Classifications and Powertype Classes

Prof. U. Aßmann, Softwaretechnologie II 1111

Facet Classifications and Powertype Classes

► Sometimes, the object universe of a class falls into several partitions, facets

► A facet is a dimension of a model■ Every facet has its separate model■ The facets are independent of each other■ Final classes in the model inherit from every dimension (every facet)

► The facets compose a type, the powertype► The following model of Living Beings has 3 facets

■ Domain (where does an animal live?)■ Age■ Group of Animal

Prof. U. Aßmann, Softwaretechnologie II 12

Powertype LivingBeing

Prof. U. Aßmann, Softwaretechnologie II 13

Facets Factorize

► Facets factorize inheritance hierarchies

Services

RefuelParking Maintenance

Facet 1

MinimalService

Cost

MiddleCheap Expensive

Facet 2

Don'tKnow

ConfiguredService Powertype Service

Prof. U. Aßmann, Softwaretechnologie II 14

Facets Can Be Implemented by Delegation

► One central facet, others are delegatees► The powertype becomes a type, with a delegatee

Services

RefuelParking Maintenance

Facet 1

MinimalService

Cost

MiddleCheap Expensive

Facet 2

Don'tKnow

ConfiguredService Powertype Service

Prof. U. Aßmann, Softwaretechnologie II 15

How Can I Recognize Facets in Modelling?

► A facet is a partition of the object universe of the powertype► A model is not a facet model, if some class exists, whose heirs do not

partition the class (non-partitioned inheritance)► If an object can belong to several subclasses or derivatives of a

class, this indicates a facet model

Gourmet Gourmand Vegetarian AllEater

TypeOfEater

SortOfEaterQualityOfEater

Powertype

Partition 2Partition 1

Prof. U. Aßmann, Softwaretechnologie II 16

Facets are Important

► UML 2.0 has facets in form of powertypes. They denote a special form of class

► Facets simplify inheritance hierarchies, because they factorize■ Less height, less breadth

► There are many complex models; use facets whereever possible.

Softwaretechnologie II, © Prof. Uwe Aßmann 17

The UML Metamodel

Prof. U. Aßmann, Softwaretechnologie II 18

18

Objects, Classes, Metaclasses

► Metadata describes data► A class can be considered as an object of the metalevel because it

describes an object on the base level► A metaclass describes a class and is part of the metamodel

<<Metaclass>>Class

Delegate()Inherit()Extend()Instantiatate()

<<Object>>Peter:Person

<<Class>>Person

Person:Class

Eat()Drink()Work()Sleep()

world model Metamodel

Prof. U. Aßmann, Softwaretechnologie II 1919

AbstractClass

Metamodel of UML

Interface

GenericClass

Class

Structure Diagram

Method Attribute

Classifier Feature

► The UML metamodel describes UML. It contains all concepts of UML as classes.

■ Here, stereotypes are described as classes.

► Some stereotypes are predefined, e.g., Interface, AbstractClass, GenericClass, Class are standard classes in the meta model of UML

► The UML metamodel models all diagram sublanguages of UML■ In the 80s, grammars were used for language specification. Now, with UML■ This indicates that UML can be used to specify languages

Prof. U. Aßmann, Softwaretechnologie II 20

Why is This Important?

► User-defined stereotypes are considered as extensions of the UML meta model

■ Every time you define a stereotype, you extend the metamodel of UML

► UML is an extensible language■ Language extensions are called profiles

► On the long run, many application domains will have their profiles for object-oriented modelling

■ Embedded and real-time systems■ Medical systems■ ...

► Your task as engineer in an application domain will be to create UML profiles and metamodel extensions

► Problem■ The UML metamodel is not modeled with facets. ■ Different aspects are mixed: not so nice!

Softwaretechnologie II, © Prof. Uwe Aßmann 21

Different Types of Class Relationships

Prof. U. Aßmann, Softwaretechnologie II 22

Different Types of Relations Between Classes

► is-a: indicates similarity■ has-same-structure: the same structure (structural equality)

► behaves-like ■ always-behaves-like: conformance, substitutability■ behaves-sometimes-like: Sometimes, A behaves-like B■ restrictedly-behaves-like: (restriction inheritance, extravagance) in

general, A behaves-like B, but not in special situations

► is-a is acyclic, sometimes tree-like► behaves-like can be symmetric

Prof. U. Aßmann, Softwaretechnologie II 23

► part-of: indicates containment [Maciaszek]■ exclusively-owns: The part cannot be switched to another owner. ■ owns: The part has only one owner. Alias-free part-of ownership ■ has-a: simple part-of. The part can be part of many entities. Aliases.■ member-of: The part can be part of many entities. all brothers are equal.■ composed-of (in UML): the part has the same life span as the whole and

cannot exist standalone

► The part-of relation in a system is acyclic ■ Can be layered

► Ownership relationships are tree-like

part-of Relation

Prof. U. Aßmann, Softwaretechnologie II 2424

Hierarchical System Decompositionwith owns-a

Car

Spark Plug

DynamoBody Work LightsWheelsEngine

Cylinder

PistonInjection Nozzle Front LightsRear Lights

No sharing

<<owns>>

<<owns>>

Prof. U. Aßmann, Softwaretechnologie II 25

Owns-A in Classes

► A class has features, i.e., attributes and methods► The part-of relationship between the class and the features is tree-

like■ In database schemas, this is called a functional relationship■ The class name is a key to the attributes

Prof. U. Aßmann, Softwaretechnologie II 2626

Layered System Decompositionwith part-of

Society

Students

SportClubFamily ChessClubGovernmentUniversity

Professors

FrankUwe SaraMary

► Part-of forms dags, sharing destroys trees

Softwaretechnologie II, © Prof. Uwe Aßmann 27

The End