You are on page 1of 22

University of Computer Studies (Yangon)

Unified Modeling Language (UML)

Dr. Myat Mon Kyaw


Associate Professor
Faculty of Information Science
Unified Modeling Language

Avoiding data replication

Links

Association
Unified Modeling Language

Lesson Goals

 To understand the essential features of the object model


 To know how to introduce them in the context of a simple
application
 To know how to present the notation of UML for illustrating object
models
 To understand the close connections between design and
programming languages
Unified Modeling Language

Avoiding data replication


Avoiding data replication Unified Modeling Language

Data replication

 Three significant problems

 It involves a high degree of redundancy.

 The replication of cost data can be expected to lead to maintenance


problems.

 The catalogue information about parts needs to be stored permanently but


no part objects of a particular type may exist in some situation.
Avoiding data replication Unified Modeling Language

Avoid data replication

 All parts of the same kind have the same attribute values (name, number,
cost)

 wasteful of resources

 hard to maintain, eg if the cost changes

 Better to create a new class for shared data

 call this a ‘catalogue entry’

 describes a type of part, do not represent individual part

 each individual part described by one entry


Avoiding data replication Unified Modeling Language

Parts and Catalogue Entries


Avoiding data replication Unified Modeling Language

Implementation

 Catalogue entry class defines shared data


 Each part holds a reference to an entry
public class Part {
private CatalogueEntry entry ;
public Part(CatalogueEntry e) { entry = e; }
}
 When parts are created, an entry is given
CatalogueEntry screw = new
CatalogueEntry(“screw”,28834,0.02);
Part s1 = new Part(screw) ;
Part s2 = new Part(screw) ;
Avoiding data replication Unified Modeling Language

Summary

 Catalogue entry object hold the information that applies to all parts of a
given types.

 It is necessary to look at both part object and related catalogue entry object
to obtain full information of a part

 The system must record for each object which catalogue entry object
describes it.

 The object diagram are a way of presenting in a visual form the structure of
object graph.
Unified Modeling Language

Links
Link Unified Modeling Language

Links

 Catalogue entry objects hold the information that applies to all


parts of a given type, where each part object represents a single
physical part.
 The system must record for each object which catalogue entry
object describes it.
 Each part object must contain a reference to the relevant
catalogue entry.
Link Unified Modeling Language

Links

 The catalogue entry class contains the data describing parts, and store
a reference to a catalogue entry.
 When a part is created, a reference to the appropriate catalogue entry
object must be provided.
 How objects are created:
Catalogue Entry screw = new CatalogueEntry (“screw”, 28834, 0.02)
Parts s1= new Part (screw);
Parts s2=new Part (screw);
Link Unified Modeling Language

Links

 References can be shown in UML as links


 object name is name of variable
 field name ‘entry’ used to label end of link
 A link is shown as an arrow pointing from the object holding the
reference to the object it refers to.
 It can be labelled at the arrowhead with the name of the field that
holds the reference.
Link Unified Modeling Language

Links

 The arrow head on the link indicates that it can only


traversed, or navigated, in one direction.
 A part object knows the location of the catalogue entry
object it is linked to and has access to its public interfaces.

Object diagram
Link Unified Modeling Language

Object Diagram

 A diagram that shows objects and links between them.


 A way of presenting in a visual form the structure of the object
graph.
 In a structure of linked objects, information is recorded in two
distinct ways:
 Data is held as attribute values in objects, other
information is held structurally, by means of links.
Unified Modeling Language

Association
Association Unified Modeling Language

Association

Data relationships between classes


Links are instances of associations
Association Unified Modeling Language

Properties of Associations

 Associations can have:


 a name (not shown)
 a rolename at each end
 derived from field name in code
 a multiplicity at either end
 this specifies how many links there can be
 an arrowhead at either end showing navigability
 derived from direction of reference in code
Association Unified Modeling Language

UML Diagram Types

 Object diagrams show objects and links

 this describes the run-time properties of a program

 Class diagrams show classes and associations

 this shows the compile-time properties of a program

 i.e. the logical structure of its source code


Association Unified Modeling Language

Object Interaction

 Objects interact by method calls


public class Part {
private CatalogueEntry entry ;
public double cost( ) { return
entry.getCost(); }
}
...
Part s1 = new Part(screw) ;
double s1cost = s1.cost() ;

 Functionality is distributed among objects which must communicate


Association Unified Modeling Language

Messages

 Object communication is shown in UML as message passing

 a message corresponds to a method call

 the class of the client object is not specified in this diagram


Unified Modeling Language

Thank You

You might also like