Sei sulla pagina 1di 22

m An object is a concept, abstraction, or thing with

identity that has meaning for an application.


m Examples : Bicycle, dog, desk, television set
m Real-world objects share two characteristics: They
all have state and behavior
m Dogs have state (name, color, breed and hungry)
and behavior (barking, fetching, wagging tail).
m A Class describes a group of objects with the
same properties (attributes), behavior
(operations), kinds of relationships.
m For example Person is a class. Each person has
name and birthdate and may work at a job.
m Another example is Car. Each car has common
attributes like number of gears, frame size, wheel
size etc.
m There are two kind of models of structure ± Class
diagram and Object Diagram.
m Class diagram provides a graphic notation for
modeling classes and their relationships.
m Class diagram are useful both for abstract
modeling and for designing actual programs.
m An object diagram shows individual objects and
their relationships.
m Object diagrams are helpful for documenting test
cases and discussing examples.
m A box represents a class and may have as many
as three compartments.
m The compartments contain, from top to bottom
m class name
m list of attributes
m list of operations.
m Optional details such as argument list and result
type may follow each operation name.
˜ 

attributeName1 : dataType1 = defaultValue1


attributeName2 : dataType2 = defaultValue2
attributeName3 : dataType3 = defaultValue3
«««««««««««««««««««««..

operationName1 (argumentList1) : resultType1


operationName2 (argumentList2) : resultType2
operationName3 (argumentList3) : resultType3
««««««««««««««««««««««.
m Each argument may have a direction, name, type,
and default value.
m The direction indicates whether an argument is an
input (in), output (out), or an input arguments that
can be modified (inout).
m A colon precedes the type.
m An equal sign precedes the default values.
m The default value is used if no argument is
supplied for the argument.
m à   
 à    
m Our convention is to list the class name in
boldface, center the name in the box, and
capitalize the first letter.
m Note how we run together multiword names, such
as JoeSmith, separating the worlds with
intervening capital letters. This is the convention
we use for referring to objects, classes, and other
constructs.
m Alternative conventions would be to use
intervening spaces or underscores.
m Class



m Objects

 
  
m A value is a piece of data.
m An attribute is a named property of a class that
describes a value held by each object of the class.
m Object is to class as value is to attribute.
m Name, Birthdate and weight are attributes of
person.
m Color, modelYear and weight are attributes of Car
objects.
m Each attributes has a value for each object.
m Class with Attributes



name:string
birthdate:date

m Object with Values


   


name=³Joe Smith´ name=³Mary Sharp´


birthdate=21 oct 1983 birthdate=16 march 1950
m An operations is a function or procedure that may
be applied to or by objects in a class.
m For example, open, close, hide or redisplay are
operations on class Window.
m All objects in a class share the same operations.
m An operation may have arguments in addition to
its target object.
m Such arguments may be placeholders for values,
or for other objects.
  

name:string color
birthdate:date position

changeJob move (delta : Vector)


changeAddress select(p :Point):Boolean
rotate(in angle:float=0.0)
m A link is a physical or conceptual connection
among objects.

 

˜

name= ³Joe Smith´
name= ³GE´
birthdate= 21 oct 1983

m For example, Joe Smith works for GE company.


m Most links relate two objects, but some links relate
three or more objects.
m A link is an instance of an association.
m An association is a description of a group of links
with common structure and common semantics.


u   ˜

name
name
birthdate
m For example, a person u   a company.
m The links of an association connect objects from
the same classes.
m An association describes a set of potential links in
the same way that a class describes a set of
potential objects.
m The UML notation for a link is a line between
objects. If the link has a name, it is underlined.
m An association connects related classes and is
also denoted by a line.
m Show link and association names in italics.
m Multiplicity specifies the number of instances of
one class that may relate to a single instance of
an associated class.
m UML diagrams explicitly list multiplicity at the ends
of association lines.
m The UML specifies multiplicity with an interval
such as
m 1 (exactly one)
m 1..* (one or more) or 3..5 (three to five)
m * (many, zero or more).
˜ 1      1 ˜
 ˜ 
name name

˜à˜      ˜


 ˜ 
name=³Canada´ name=³Ottawa´

ë˜       ˜


 ˜ 
name=³France´ name=³Paris´

[à ˜     


  ˜
 ˜ 

name=³India´ name=³Delhi´
à 1      
name name

Rà 6[˜
name=³Ram´ name=³ANSIC´

 à 
6

name=³Syam´ name=³OODA´

à ˜
name=³Laxman´ name=³CN´
  
   ˜

name name


˜

name=³John´ name=³GE´

  ˜




name=³Mary´ name=³LG´

6 
name=³Alice´
m For each association there is at most one link
between a given pair of objects.

     
6 

  
66 aB:B
m If you want two links between the same objects,
you must have two associations.
     
6 
     

  
66 
  

Potrebbero piacerti anche