s10

Document Sample
s10 Powered By Docstoc
					      Software Design Methodologies:
              UML in Action


                Dr. Mohamed Fayad, J.D. Edwards Professor
                Department of Computer Science & Engineering
                University of Nebraska, Lincoln
                Ferguson Hall, P.O. Box 880115
                Lincoln, NE 68588-0115
                http://www.cse.unl.edu/~fayad



May-June 2001                     ISISTAN Research Institute – Tandil,
                                             Argentina
                  Lesson 11:
                Object-Oriented
                  Concepts -2
                                                                              2
May-June 2001      ISISTAN Research Institute – Tandil,   L11-S2   OO Concepts -2
                         Argentina -- M.E. Fayad
                       Lesson Objectives


                    Review of previous lecture
                    Discuss associations
      Objectives    Explore recursive associations,
                   attributed association
                    Understand association constraints
                    Understand qualified & derived
                   associations
                    Discuss UML – aggregation


                                                                                  3
May-June 2001          ISISTAN Research Institute – Tandil,   L11-S3   OO Concepts -2
                             Argentina -- M.E. Fayad
                              Associations
           An association shows a two-way relationship between
            objects (instances) of two or more classes and requiring
            special implementation to ensure integrity.

           A particular instance of an association is often called a link.

           Associations between classes are required if the objects
            need to communicate.

           Associations are often named, and have role-names for
            each side of the link.

                                                                                          11
May-June 2001                  ISISTAN Research Institute – Tandil,   L11-S4   OO Concepts -2
                                     Argentina -- M.E. Fayad
                             More on Associations

                             Association Name

                   Car                                                       Person
                                    Vehicle Registration
                model                                                       name
                year              registeredCar                     owner   age
                # of doors                                                  address



                                          Roles Names

                                                                                                 5
May-June 2001                        ISISTAN Research Institute – Tandil,   L11-S5    OO Concepts -2
                                           Argentina -- M.E. Fayad
                     More on Associations
      Simple example:

                                    displays            0..*
                  Window                                         GeomFigure


      An association has a name and a numerical specification (multiplicity
       indication) of how many objects on one side of the association are
       connected with how many objects on the other side.

      Associations are called use relationships – even if this may seem
       somewhat cheeky in the example below


                                employs                          0..*
                Company                                                 Person
                           Employer                     Employee
                                                                                             6
May-June 2001                  ISISTAN Research Institute – Tandil,      L11-S6   OO Concepts -2
                                     Argentina -- M.E. Fayad
                         More on Associations
           Associations are directed (one way), bidirectional, and
            undirected.

           UML makes no distinction between bidirectional and
            undirected associations.

                                           Multiplicity


                                      Stereotype
                                      RelationName
                           1          {Constraints}                       *
                Class1                                                         Class2
                           role1                      Role2: interface
                                                                                                   7
May-June 2001                      ISISTAN Research Institute – Tandil,       L11-S7    OO Concepts -2
                                         Argentina -- M.E. Fayad
                      More on Associations
           Recursive association: A class has a relation with itself.
           It is also possible to model associations that are valid only
            temporarily “stereotype or temporary”
           Constraints may be used to restrict the relation under
            specific aspects.
           A role name describes how the object is seen by the
            opposite object in the association.
           An association can be described in more detail by means of
            constraints, tagged values, and stereotypes.
           Stereotypes are noted before or above the relation name,
            constraints, and tagged values after or below the name.                      8
May-June 2001                 ISISTAN Research Institute – Tandil,   L11-S8   OO Concepts -2
                                    Argentina -- M.E. Fayad
                         More on Associations
           Directed association is a one-way association, in
            which one side knows the other, but not vice versa.

           Multiplicity Specification:
                – 1        exactly one

                – 0, 1     zero or one

                – 0..4     between zero and four

                – 3, 7     either three or seven


                                                                                         9
May-June 2001                 ISISTAN Research Institute – Tandil,   L11-S9   OO Concepts -2
                                    Argentina -- M.E. Fayad
                         More on Associations
           More multiplicity specifications:
                – 0..*       greater than or equal to zero (default)

                – *          ditto

                – 1..*       greater than or equal to one

                – 0..3, 7, 9..* between zero and three, or exactly seven, or
                  greater than or equal to nine.




                                                                                             10
May-June 2001                    ISISTAN Research Institute – Tandil,   L11-S10   OO Concepts -2
                                       Argentina -- M.E. Fayad
                          More on Associations
           Recursive associations are associations in which one
            class is involved.

                                                                                  has
                                                                                                 Patient
                   Employee

                   name
                                       office clerk                               relative
                   staffNo
                   roomNo            *                                        *

                manager   1                                                   Person
                                   leads

                              reports to
                                                                                                                 11
May-June 2001                              ISISTAN Research Institute – Tandil,        L11-S11        OO Concepts -2
                                                 Argentina -- M.E. Fayad
                         N-ary Association
           An n-ary association is like a common (binary)
            association, except that more than two association
            roles involved in it.

                                        N-ary
                                     association
                Class1                                                    Class2



                                                                    Ternary
                                                                  association
                                        Class3
                                                                                           12
May-June 2001              ISISTAN Research Institute – Tandil,      L11-S12    OO Concepts -2
                                 Argentina -- M.E. Fayad
                More on n-ary Association
                                         Reservation
                  Train                                                         Seat
                            1                                     1..*
                   date                                                     carriageNo
                 trainNo                                                      seatNo




                                                  1..*
                                          Passenger
                                            name                           Ternary
                                             title                       association
                                                                                                  13
May-June 2001              ISISTAN Research Institute – Tandil,           L11-S13      OO Concepts -2
                                 Argentina -- M.E. Fayad
                      More on Associations
                • Recursive Associations
                • N-ary Associations
                • Attributed Associations (Association Class)
                • Association Constraints
                • Qualified Associations
                • Derived Associations
                • Directed Associations
                • Ordered Associations
                • Realization/Refinements
                • Dependency                                                              14
May-June 2001                 ISISTAN Research Institute – Tandil,   L11-S14   OO Concepts -2
                                    Argentina -- M.E. Fayad
                More on Associations
  Associations are usually bidirectional
         Allows each object involved in the relationship
         to refer to the object to which it is related.

         Bidirectional association means at the
         relationship has an inverse.

         Associations do not have to be bidirectional.
                                                                                    15
May-June 2001           ISISTAN Research Institute – Tandil,   L11-S15   OO Concepts -2
                              Argentina -- M.E. Fayad
      Man           Marriage                 Woman              Association Type
                husband             wife
                                                                One-to-One


     Screen         Windows                 Window
                                                                One-to-Many
                                                                (One-to-Zero-or-More)


      Nets          Authorization            User
                                                                Many-to-Many


    Car                                     Trailer
                                                                Zero or One
                                                                                           16
May-June 2001                  ISISTAN Research Institute – Tandil,   L11-S16   OO Concepts -2
                                     Argentina -- M.E. Fayad
                                                                  Association Type
     Square              Sides                    Line
                                                                  Specified the # of instances
                                                                  on the “many” side

Secure Room              Occupants               Person
                                                                  Specify the possible # of
                                                                  instances using “or”


                   TraditionalFamily
     Male                                       Female
                                                                  Ternary relationship
                father           mother


                             children

                         Child
                                                                                              17
May-June 2001                        ISISTAN Research Institute – Tandil,   L11-S17   OO Concepts -2
                                           Argentina -- M.E. Fayad
                     Association Class
   Server            Connection                         Client



                       Connection

                       baudRate                  • These attributes don’t belong
                       protocol                  in either the Client or Server
                       wireType                  class.
                                                 • They are attributes of the
                       disconnect
                       rerouteLink               connection itself.



 • The association class can have behaviors as well as attributes.
                                                                                    18
May-June 2001              ISISTAN Research Institute – Tandil,   L11-S18   OO Concepts -2
                                 Argentina -- M.E. Fayad
                    Aggregation & Composite
               Aggregation is a special form of association.

               Aggregation is used when the relationship is
                “part/whole” or “contains/is-part-of”

               Aggregation is transitive and operations on
                “whole” often cascade down to “parts”.

                                                                                          19
May-June 2001                 ISISTAN Research Institute – Tandil,   L11-S19   OO Concepts -2
                                    Argentina -- M.E. Fayad
                    Aggregation & Composite

        Server                                    Computer
                          Aggregation




                “whole”
     52         “part”                                     *
       Client                 CPU              Disk Drive              Keyboard        Mouse




                                                                                                 20
May-June 2001                       ISISTAN Research Institute – Tandil,    L11-S20   OO Concepts -2
                                          Argentina -- M.E. Fayad
                  Aggregation & Composite
           Special diamond symbol used on “whole” side to indicate
            aggregation.

           Aggregation is an anti-symmetric that is, if A is part of B,
            then B is not part of A.

           DO NOT confuse aggregation with generalization

           An essential property of aggregates is that the whole acts
            as a proxy for its parts.

           A composition is a strict form of aggregation, in which the
            parts are existence-dependent on the entirely                                  21
May-June 2001                  ISISTAN Research Institute – Tandil,   L11-S21   OO Concepts -2
                                     Argentina -- M.E. Fayad
                Aggregation & Composite

                              Aggregation

                 Entirely                                             Part



                Composition
                                                                     Existence-
                                                                     DependentPart




                                                                                           22
May-June 2001                 ISISTAN Research Institute – Tandil,    L11-S22   OO Concepts -2
                                    Argentina -- M.E. Fayad
                    Aggregation Problem

                   Mr. Clinton’s hand is part-of Mr. Clinton & Mr.
                    Clinton is part-of U.S.A.



                   Therefore:



                   Mr. Clinton’s hand is part-of U.S.A.
                                                                                        23
May-June 2001               ISISTAN Research Institute – Tandil,   L11-S23   OO Concepts -2
                                  Argentina -- M.E. Fayad
                                      Keypad


                                                                        Cash Register
                                                                          Example

       *
    Number Keys                        Total Key                         Subtotal Key




                display     display                                                  display
                                                                 drawer

                      Display                                          Drawer

                                                                                                24
May-June 2001                   ISISTAN Research Institute – Tandil,       L11-S24   OO Concepts -2
                                      Argentina -- M.E. Fayad
                Aggregation vs. Inheritance
     Aggregation                                   Inheritance

     Instances of distinct classes                 Instances of a single class

     “a-part-of”          (APO)                    “a-kind-of” or “is-a” (AKO)

     Contains                                      superclass-of

     Aggregate + parts                             Superclass + subclass

     “and” relationship                            “or” relationship

     Propagated only if specified                  Inheritance                             25
May-June 2001                  ISISTAN Research Institute – Tandil,   L11-S25   OO Concepts -2
                                     Argentina -- M.E. Fayad
                    Discussion Questions
                •   What is an association? Give examples
                •   Associations are usually bidirectional. Please describe.
                •   Describe the basic difference between aggregation and
                    inheritance. What do they have in common?
                •   What do you think “multiple inheritance” means?
                •   Which type of association is more likely to yield savings in the
                    amount of code required for implementation? why?
                •   Define the process of identifying objects, classes, inheritance,
                    associations & aggregation, attributes, and behaviors
                •   Define Polymorphism with examples
                •   What do we mean by saying “Model/View/Controller”?
                                                                                       26
May-June 2001              ISISTAN Research Institute – Tandil,   L11-S26   OO Concepts -2
                                 Argentina -- M.E. Fayad
                 Questions for the Next Lecture

                Define:
                   – Use Case
                   – Structured English

                What are the good, bad, and ugly of Use
                 Case?




                                                                                 27
May-June 2001        ISISTAN Research Institute – Tandil,   L11-S27   OO Concepts -2
                           Argentina -- M.E. Fayad

				
DOCUMENT INFO
Categories:
Tags:
Stats:
views:4
posted:10/23/2011
language:English
pages:27