Академический Документы
Профессиональный Документы
Культура Документы
nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Objects
An object is a thing that can be tangible or intangible. Examples tangible : bike, car, house intangible : order, account An object has properties. Example a Customer has a name and address
Customer Name Address
7M822
www.ddss.arch.tue.nl
(Multiple) Objects
Property of object = attribute + value
Adacs: Customer Name = Adacs Address = Enschede Primo: Customer Name = Primo Address = Grave
www.ddss.arch.tue.nl
345T7: Order
Orderno = 345T7 dateReceived = 10/10/05 Price = 1987
7M822
www.ddss.arch.tue.nl
Class
Class class is abstract concept each object is instance of a class classes classify objects attribute has no values
Customer
Custno Name Address
Order
Orderno dateReceived Price
www.ddss.arch.tue.nl
Class Diagram
Attribute has no values Association is relation between classes
Customer Custno Name Address Order Orderno dateReceived Price
7M822
www.ddss.arch.tue.nl
Class diagram
A class diagram describes the type of objects in a system and the static relationships between them.
Static relations:
Associations
7M822
www.ddss.arch.tue.nl
Class operations
An operation is the implementation of a service that can be requested from any object of the class in order to affect behaviour. Operations are used to manipulate the attributes or to perform other actions. Operations are normally called functions, but they are inside a class and can be applied only to objects of that class. An operation is described with a return-type, a name and zero or more parameters. Together, the return-type, name, and parameters are called the signature of the operation. The signature describes everything needed to use the operation.
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Class - associations
Associations are structural relationships where instances (objects) of one class are connected to instances (objects) of another class.
an employee works for a company a company has a number of offices
An association is normally bidirectional, which means that if an object is associated with another object, both objects are aware of each other (navigation is bidirectional by default). Binary association connects exactly two classes. N-ary connects many classes. The most common association is just a connection between classes.
7M822
www.ddss.arch.tue.nl
Person
works for
Company
employee
employer
Person
has employment for
Company
7M822
www.ddss.arch.tue.nl
Associations: multiplicity
Multiplicity defines the number of objects associated with an instance of the association.
Default of 1 (1: 1) 0 or 1: 0..1 Zero or more (0..infinite): * 1 or more (1..infinite): 1..* n..m; range from n to m inclusive
transports
Car
passenger
Person
transports 5
Car
passenger
Person
transports *
Car
passenger
Person
transports 1..*
Car
passenger
Person
transports 2..5
Car
passenger
Person
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Generalization
A specialization / generalization relationship, in which objects of the specialized element (child) are substitutable for objects of the generalized element (parent).
Superclass the generalization of another class, the child. Subclass the specialization of another class, the parent.
Customer
Corporate Customer
Personal Customer
7M822
www.ddss.arch.tue.nl
Generalization - characteristics
Identify common features concerning behaviour and knowledge. Define these common features on a higher level in the inheritance hierarchy. The aim is at behaviour more than knowledge when combining classes. Generalization is a bottom-up process. A superclass includes all common properties of its subclasses.
7M822
www.ddss.arch.tue.nl
Specialization - characteristics
Define a new class which is a special appearance of an existing class. Specialization is a top-down process. A subclass can have attributes and operations that are specific for that sub-class. A subclass may redefine operations of its super-class
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Constraints
The basic constructs of association, attribute, and generalization do much to specify important constraints. They cannot indicate every constraint. These constraints still need to be captured; the class diagram is a good place to do that. The UML allows you to use anything to describe constraints. The only rule is that you put them inside braces { }.
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Attribute analysis
It is not always clear which attributes belongs to which classes by finding out the class attributes. An attribute is assigned to that class where it is certainly a feature.
For example: a project leader has the attributes name, department and age.
But what to do with the attributes project number, project duration, starting time, and budget? These attributes clarifies something about the relation between project leader and type of project.
This often happens if a n:m relation refers to an association between two classes. In that case, we can define a new class, for instance project management.
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Board 1 * 64
Pawn
Bishop
Knight
Rook
Queen
King
7M822
www.ddss.arch.tue.nl
Object diagram
An object diagram is a diagram that shows a set of objects and their relationships at a point in time; object diagrams address the static design view or static process view of a system. An object diagram is shown as a class, and the name is underscored, although an objects name can be shown optionally preceding the class name as: objectname: classname. The object does not have to be named, in which case only the classname is shown underscored.
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
+ : public
{f is public f is visible to any object and f is inherited by the subclasses of C.}
# : protected
{f is private f is visible only to O and f is not inherited by the subclasses of C.}
- : private
(f is protected f is visible only to objects of class C and to objects of Cs subclasses and f is inherited by the subclasses of C.}
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Class object
Objects are abstractions of real-world entities.
Objects encapsulate state and represent information.
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Composition is a form of aggregation with strong ownership and coincident lifetime of the parts by the whole; the part object may belong to only one whole the parts are usually expected to live and die with the whole.
{usually, any deletion of the whole is considered to cascade to the parts}{filled diamond}
7M822
www.ddss.arch.tue.nl
1
1 1 1
1
1..*
1..2 Monitor
*
Floor
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Qualified Associations
The qualifier specifies how a specific object at the many end of the association is identified, and may be seen as a kind of key separating all the objects in the association.
7M822
www.ddss.arch.tue.nl
7M822
www.ddss.arch.tue.nl
Reflexive Associations
A class has an association to itself.
Example: A directory may contain other directories.
subdirectory 0..*
Directory
0..*
File
0..1 parent
7M822
www.ddss.arch.tue.nl
References
Sommerville, Ian (2001)
Software Engineering, 6th edition http://www.software-engin.com
7M822