Creating Design Class Diagrams

Document Sample
Creating Design Class Diagrams Powered By Docstoc
					Creating Design Class Diagrams




                                 OOA&D - v3.2 - English
Object-Oriented Analysis and Design
 Overview

     Design class diagrams illustrate information about software class
      definitions.
     We explore:
        When.

        Notation.

        Guidelines.

        Practice.




                       Chapter 13: Creating Design Class Diagrams   v3.2   2
Object-Oriented Analysis and Design
 Objectives

    Read and create design class diagrams.
    Add methods to the diagram.
    Illustrate visibility.
    Define and contrast reference
     and simple attributes.




                              Chapter 13: Creating Design Class Diagrams   v3.2   3
Object-Oriented Analysis and Design
  A Sample Partial Process


                                              Dev           Dev          Dev
                                             Cycle 1       Cycle 2      Cycle ...




         Refine          Update                                        Con-
                                          Analyze         Design                    Test
          Plan           Artifacts                                     struct




      1. Define Real Use             2. Define Reports,       3. Refine System      4. Refine
      Cases                          UI and Storyboards       Architecture          Interaction Diags.


      5. Define Design               6. Define Database
                                                              ...
      Class Diagrams                 Schema




                                     Chapter 13: Creating Design Class Diagrams               v3.2       4
Object-Oriented Analysis and Design
 Design Class Diagrams

 Design class diagrams depict software class definitions.
    Methods.
    Attribute visibility.
    Simple attributes.

                                                              Resource
              Catalog
                                  Contains 4           title : String
                                                       callNumber : Number
                              1                   *    subject : String
         getResource()
                                                       getDueDate()




                          Chapter 13: Creating Design Class Diagrams     v3.2   5
Object-Oriented Analysis and Design
 Showing Attribute Visibility

 Attribute visibility should be shown when a permanent connection
 is required.
     Add a UML navigation arrow on the association.

                     Library                                                  Catalog
                                                  Maintains
               address
                                      1                             1
               addLoan()                                                getResource()


                                      Navigation arrow indicates
                                      attribute visibility from a
  Library has 2 attributes:           Library to a Catalog.
  1) address : Address                                                       Catalog has no
  2) myCatalog : Catalog                                                    attributes.
                                      "myCatalog" is an implied
                                      attribute; not explicit.



                               Chapter 13: Creating Design Class Diagrams            v3.2     6
Object-Oriented Analysis and Design
 Simple and Reference Attributes

     Reference attributes refer to other complex objects.
        Implied by associations in the diagram.
     Simple attributes are relatively primitive types.
        number, string, boolean, address, ...

                Library                                                Catalog

           address : Address                 Maintains
           revenue : float     1                              1
                                                                  getResource()
           addLoan()
                                   class Library
                                   {                                  simple
                                   private Address address;           attribute
                                   private Float revenue;
                                   private Catalog catalog;
                                   // ...                             reference
                                   }                                  attribute



                           Chapter 13: Creating Design Class Diagrams             v3.2   7
Object-Oriented Analysis and Design
 Showing Temporary Visibility

  Temporary visibility is associated with parameter or local visibility.


            Library                                                     Catalog

      address : Address                   Maintains
      revenue : Money       1                                1
                                                                  getResource()
      addLoan()

                                                                        Resource

      A UML dependency association.                               ...

      Indicates any kind of dependency.                           ...

      Useful to show temporary visibility.




                          Chapter 13: Creating Design Class Diagrams          v3.2   8
Object-Oriented Analysis and Design
  Adding Methods


           borrowResource(callNum)



                   1: r := getResource(callNum): Resource
     :Library                                                          :Catalog


 collaboration diagram



                                                                      Catalog

 partial DCD
                                                               getResource()




                         Chapter 13: Creating Design Class Diagrams        v3.2   9
Object-Oriented Analysis and Design
 Showing Methods Details

     Method details are optional.
     When are they useful?
        Automatic code generation.

        Communication of detailed specifications to developers.




           1: r := getResource(callNum): Resource                :Catalog



                                   Catalog



                getResource(callNum : Integer) : Resource


                        Chapter 13: Creating Design Class Diagrams          v3.2   10
Object-Oriented Analysis and Design
 Showing Template Classes



                        T
            Vector


                                      Relevant to C++ and Ada.
   find()
   add()                              Example: C++ STL templatized
   ...                                containers.




                     Chapter 13: Creating Design Class Diagrams   v3.2   11
Object-Oriented Analysis and Design
  Partial DCD Example


                                                Catalog                        Loan

                                                                        dueDate : Date

                                          getResource()

                                                        1                          0..1
                              Records-storage-of
                                                        *
                                                                 Records-loan-of
                                               Resource
          Patron
                                         callNumber : Integer     1
  libraryID : Integer      Borrows       subject : string
                        0..1         *   title : string

                                         getDueDate()




                           Chapter 13: Creating Design Class Diagrams           v3.2      12
Object-Oriented Analysis and Design
 Optional Exercise

 As far as possible, name and draw “influence lines” between artifacts.
                  Sample                     Sample                   Sample
         Analysis-oriented artifacts Design-oriented artifacts   Software artifacts




                                Chapter 13: Creating Design Class Diagrams            v3.2   13
Object-Oriented Analysis and Design
 Exercises

  Create a design class diagram for the course project.




                      Chapter 13: Creating Design Class Diagrams   v3.2   14
Object-Oriented Analysis and Design
 What We Learned; Reflection

     Design Class Diagram - Software classes with illustrated methods
      and attribute visibility.

     Reflection - Design Class Diagram.
        Value? Use at work?

        Relationship to other artifacts and tasks?




                         Chapter 13: Creating Design Class Diagrams   v3.2   15
Object-Oriented Analysis and Design
  Skill and Objectives Evaluation


                       Skill                             Yes/no or comment

   Read design class diagrams in UML
   notation.

   Create a design class diagram in UML
   notation.

   Add methods to DCD.

   Add attribute visibility to DCD with
   navigation arrows.




                        Chapter 13: Creating Design Class Diagrams   v3.2    16