UML Class Diagrams Sequence Diagrams - PowerPoint by ias80075

VIEWS: 0 PAGES: 23

									UML Class Diagrams
 Sequence Diagrams

  CS2335
Summer 2002
                            Agenda

• Class Diagrams
  – Symbology
  – Basic Modeling
  – Intermediate Modeling
• Sequence Diagrams
  – Symbology
                         Class Diagrams
• A class diagram shows:
  – Classes
    • Attributes
    • Methods
  – Interfaces
  – Collaborations
  – Dependency, Generalization, Relationships
• A class diagram is a STATIC view of
  system
Basic Class Diagrams

 Class Name

 Class Attributes



 Class Methods
                       Basic Class Diagrams
+      public
#      protected
                             Abstract
-      private
                             <<abstract>>
/      derived                              <<constructor>>
$      static                               <<query>>
                                            <<update>>
Class Scope Variable                        …
Visibility Attribute Name [Multiplicity]:Type = Initial Value

Visibility Method Name (Parameter List) : Return-List
                   Basic Class Diagrams

 Superclass        Class with
                      parts           Note



                    Assembly
  Subclass            Class         name


  Inheritance      Composition   Association
                   (Part-Of)     (relationship)
(Generalization)
(is-a, kind-of)
    Basic Class Diagram (Example)
Brain      Person




Money                        Class
           Student

                     takes
Basic Class Diagram (Example)

          Person

+ name : String
- ssn : String
# birthday : Date
/ age : int

+getName : String
-calculateAge : int
       Class Diagrams (Advanced)

Cardinality (Multiplicity)
1
0..1
0..n
1..n
*
                                            Class
                Student

                             takes   0..n
            Class Diagrams (Advanced)
Important Stereotypes:
<<interface>> specify collection of operations to specify
              services
<<type>> specify structure and behavior (not implementation)
<<enumeration>> specify discrete values
<<implementationClass>> helper class created in detail design

   <<interface>>      <<type>>        <<enumeration>>
   ImageReader        Complex             Status
                    Fundamental        Idle
                    Attributes         Working
    readImage       Fundamental        Error
    writeImage      behavior
          Class Diagrams (Advanced)

   Simple Aggregation (object lifetime)

    Composite Aggregation (unique member)


  Can have self-relations:       Exception handling:


manager
                                     <<sends>>
                manages
  employee
Class Diagrams (Advanced)
                      Book
Patron




         Checks Out

                         Association
                         Class
                Class Diagram Hints
• Provide abstraction of problem domain
• Embodies small set of well-defined
  responsibilities
• Clear separation between specification
  and implementation
• Understandable and simple
• Show only important properties
                            Class Hints
• Organize similar classes into packages
• Beware of cyclical generalization
• Use associations where there are
  structural relationships
• Associations are NOT comm pipes!!!!!!!
• Start with Analysis, then refine details
Bitman Class Diagram
                Sequence Diagrams
• AKA Interaction Diagrams – Semantically
  equivalent to Collaboration Diagrams
• Dynamic Model relating use cases and
  class diagrams
• Shows time ordering of interactions
• Generally a set of messages between
  collaborating objects
• Ordering of objects not significant
                 Sequence Diagrams
• Show only one flow of control
• May need multiple diagrams
  – Primary
  – Variant
  – Exceptions
       Sequence Diagram (Basic)
Swimlane

                 Object : Class or Actor

           Lifeline
                                      name
           Focus of
           Control/
           Activation
                                     message
             Object
   X
             Destruction/          <<create>>
             Termination           <<destroy>>
Sequence Diagram (Basic) Example

                aClass:          :Scheduler
                Class
Student
          Register
                          adjustRoom    checkRooms
Sequence Diagrams (Advanced)

Seq# [Guard] *[Iteration] Return-List :=
      Operation-Name (Argument-List)

              *[Iteration Condition]


     recursion

                           Conditional
                           Lifeline        {transient}
    Sequence Diagrams (Advanced)
                        Example
          ob1:             ob3:
          C1               C3        {transient}     :C4
User run(v)
                  <<create>>           ob2:
                      [x>0] foo(x)     C2
                                               doit(w)
                 [x<0] bar(x)                *[7]doit(z)


                 <<destroy>>
                                         X
       Sequence Diagram (Hints)
• Can show either objects or processes
  (<<process>>) in swimlanes
• Use multiple diagrams to show
  variations
• Use advanced features sparingly to
  keep diagram understandable
Lab 4 Exercise

								
To top