Systems Analysis II Class and Object Diagrams - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

Systems Analysis II Class and Object Diagrams

Description:

If you draw the class diagram at one moment, and only show the objects which ... Object Diagrams ... A Car is made up of Part(s) ... – PowerPoint PPT presentation

Number of Views:35
Avg rating:3.0/5.0
Slides: 45
Provided by: Gle780
Category:

less

Transcript and Presenter's Notes

Title: Systems Analysis II Class and Object Diagrams


1
Systems Analysis IIClass and Object Diagrams
  • INFO 355
  • Glenn Booker

2
More Class Diagram Concepts
  • Beyond what was covered in week 3, there are
    additional concepts and corresponding notations
    which may be used in class diagrams
  • They are grouped here into
  • Class and Object Concepts
  • Association Concepts
  • Attribute Concepts

3
Visibility
  • Visibility applies to a class, its attributes,
    and methods
  • Options are public, private, and protected, but
    their exact meaning differs by programming
    language
  • Public is designated by a sign, and means
    things outside the class can see it and use it

4
Visibility
  • Private is shown with a prefix, and means that
    thing is only visible within that class
  • Protected is shown with a prefix, and means
    something like it can be seen by that class
    generalization hierarchy, but not outside that
  • By default, attributes are private classes and
    methods are public

5
Class and Object Concepts
6
Abstract Classes
  • Abstract classes are used in implementation to
    show a superclass that is only used via its
    subclasses
  • The abstract superclass is never instantiated
    into an object
  • The abstract class is shown by putting its name
    in italics
  • In Visio, check the box IsAbstract

7
Interface Classes
  • An interface is an abstract class with all
    abstract features
  • A class provides an interface if it implements
    that interface
  • A class requires an interface if it is dependent
    upon an object from that interface

8
Interface Classes
  • This is a different sense for interface than the
    model/view/ controller breakdown
  • There is a special element in Visio for interface
    classes
  • Interfaces are shown in interaction diagrams with
    a lollipop

9
Interface Classes
  • An interface class could refer to a connection to
    an external system
  • Have that interface class be the gateway to that
    external system from anywhere within your system

Also called a façade pattern
10
Interface Classes
  • Or they could be a connection to somewhere else
    within your system, such as an interface class
  • Treating human interfaces as an interface objects
    allows data objects to send output directly to
    them
  • Have the data object send output to an abstract
    interface class, which in turn points to the
    actual user interface

11
Generalization and Classification
  • Generalization is often assumed to have an
    implied verb phrase of is a
  • Beware that sometimes the intent is really
    classification
  • Classification means the thing (object) is an
    example of the supertype
  • My dog Hajime is an example of a Black Lab
    therefore, it is a classification
  • Show classification with an ltltinstancegtgt
    constraint

12
Generalization and Classification
  • Generalization means the thing is a subtype of a
    supertype they have traits in common in the
    supertype, but each subtype has unique traits
  • A poodle is a subtype of Dog all Dogs have
    common traits, but poodles have certain size and
    shape characteristics
  • Use the generalization symbol

13
Multiple Classification
  • Conceptually, it is possible for one superclass
    to have many types of classifications (p. 77)
  • In such cases, it is acceptable to choose one
    value from each generalization hierarchy
  • Hard to define all legal combinations
  • Difficult to implement in code, hence only used
    conceptually

14
Association Classes
  • An association class is a class which depends on
    the existence of an association between two other
    classes

15
Association Classes
  • Notice that there is no multiplicity shown on the
    association class line ends it is always assumed
    to be 1
  • The association class adds a constraint
  • You can only have one entry (instance of the
    association class) for each combination of the
    other two classes

16
Association Classes
  • Be wary of creating association classes
  • Consider whether the same class could just be a
    normal class, or if the constraint adds meaning
  • Often helps clarify many-many multiplicities

17
Active Classes
  • An active class is a controller class that
    manages its own threads based on inputs
  • UML 2 has a double line symbol (p. 83)
  • Check the IsActive box in Visio it thickens the
    lines a little in UML 1.x
  • Good for an independently operating process or
    daemon

18
Object Diagrams
  • The class diagram represents all classes which
    could exist in your system
  • If you draw the class diagram at one moment, and
    only show the objects which exist at that moment,
    you have an object diagram

19
Object Diagrams
  • This is used to help navigate complex use cases,
    when it isnt clear what objects have been
    created or destroyed
  • You could consider the object diagram like a
    collaboration diagram without messages

20
Object Diagrams
  • Make sure to note the full object names,
    IvanPerson
  • Actual values for attributes can be shown (p. 88)

21
Association Concepts
22
Association Navigability
  • Now we can explicitly state whether an
    association can go in only one direction or
    another
  • Ask yourself if either class might need to call
    upon a method in the other class
  • An Invoice might add or remove LineItem(s), but
    will a LineItem ever create an Invoice?

23
Association Navigability
  • If its a one-way association, in Visio, check
    the correct box in the line properties for
    IsNavigable
  • Leave the line with no arrows if its
    bidirectional

24
Association End Labels
  • The ends of associations can be labeled
    separately
  • Frequently helpful for hierarchical associations

25
Aggregation
  • Aggregation is used to show when parts make up
    the whole of something else
  • A Club class is made up of Member(s)
  • A Car is made up of Part(s)
  • The notation for aggregation is an open diamond
    on the collective side of the association (Club
    or Car)

26
Aggregation
  • To get this line in Visio
  • Start with a Composition line
  • Double click on it
  • Change the Aggregation type from Composite to
    Shared
  • Edit multiplicity and line ends

27
Composition
  • A concept similar to aggregation is composition
  • Composition is used to show properties of a class
    that are strongly owned by each object
  • The composite does not imply ALL properties of
    that class, just an important one
  • The diamond is filled in for composition

28
Composition
  • For examples
  • A Polygon is defined by three or more Point(s) in
    some ordered sequence
  • A Circle has a Point which is the center of that
    circle
  • Hence the example in figure 5.4 (p. 68)

29
Aggregation and Composition
  • Aggregation doesnt affect a class diagram much,
    but its nice to show the relationship where it
    applies
  • Composition is fairly rare, but can show critical
    connections among classes
  • What do Class A and Class B have in common? They
    share a composition with Class C.

30
Qualified Associations
  • A qualified association can be used to refine the
    multiplicities of an association by specifying an
    attribute through which the association is made

31
Qualified Associations
  • The multiplicity of the qualified association
    (itemID) is always 1
  • The other multiplicity is based on one example of
    the qualified association (one itemID associates
    with exactly one ProductSpecification)
  • Could express as there is one ProductSpecificatio
    n per itemID in the ProductCatalog

32
Attribute Concepts
33
Static Attributes and Methods
  • Static means the attribute or method applies to
    the class, not its instances (objects)
  • Analogous to the C concept of static, if an
    attribute or method is static, its name is
    underlined on the class diagram
  • I cant find a Visio way to show this add a
    stereotype of ltltstaticgtgt?

34
Derived Attributes
  • In a class diagram, attributes which are derived
    (calculated) from other attributes can be shown
    if they are significant
  • Normalization doesnt apply to classes!
  • Put a front slash / in front of the attributes
    name to show you are deliberately using a derived
    attribute

35
Derived Attributes
  • A Note box (text box with upper right corner
    dog-eared) can be used to show how the derived
    attribute is calculated (Fig 5.5)

Note box
36
Attribute Data Types
  • As shown in the example on slide 35, each
    attribute can show its data type, using the
    format
  • attributename datatype
  • startdate Date
  • This is easy for primitive, or built-in data
    types how deal with non-primitive data types?

37
Primitive vs. Non-Primitive Data
  • Recall primitive data (attribute) types are the
    most basic ways to represent data in a computer
  • Boolean, Date, Number, String, Time
  • More elaborate data types are considered
    non-primitive

38
Attribute Types
The primitive data types are in bold others are
non-primitive
39
Non-Primitive Data Types
  • Use non-primitive if any of the following
    guidelines apply
  • Data has separate sections (phone)
  • There are operations associated with it (SSN)
  • It needs other characteristics (start and end
    date, for example)
  • It has units (height, , seconds)
  • Or any other complex concept (UPC)

40
Non-Primitive Data Types
  • So a credit card number is a non-primitive data
    type, since it has
  • Type of card (Visa/MC/Discover)
  • Fixed length depending on type
  • Validation rules based on first digit
  • Non-primitive data can be shown as separate
    conceptual classes, or just flagged as specific
    data types

41
Non-Primitive Data Types
Example Class is called ProductSpecification. One
attribute is called id, which is of the
non-primitive data type ItemID. This is the
equivalent
42
Attributes with Units
  • Things with units (, ft., lb., etc.) need to be
    modeled with non-primitive data types
  • This helps support international-ization and
    conversion to other measurement systems (e.g.
    dollars to Euros, or English to metric units)

43
Non-Primitive Data Types
  • Non-primitive data type classes can be shown
    separately from the rest of the class diagram
    (to avoid clutter)
  • This is the only exception to the need for every
    class to be explicitly associated with at least
    one other class, since the association is
    implied

44
Enumeration Classes for Attributes
  • A class can be defined to contain only the
    elements of a list or enumerated attribute (p.
    83)
  • The ltltenumerationgtgt stereotype is added before
    the class name
  • This is like using a class to define any other
    non-primitive attribute
  • In Visio, based on the Data Type class
Write a Comment
User Comments (0)
About PowerShow.com