Docstoc

UML – CLASS DIAGRAM - Mahmoud

Document Sample
UML – CLASS DIAGRAM - Mahmoud Powered By Docstoc
					          UML – CLASS DIAGRAM
What is a class diagram?
The class diagram is a static model that shows the
classes and the relationships among classes in the
system
class diagrams illustrates classes, interfaces, and their
associations They are used for static object modeling
A Class diagram gives an overview of a system by
showing its classes and the relationships among them
Class diagrams display what interacts but not what
happens when they do interact

1                     www.mahmoud-a.com
           UML – CLASS DIAGRAM
What is a class?
The main building block of a class diagram is the class,
which stores and manages information in the system
A blueprint that an object made from
what are the contents of the class?
The class contains two major parts:
   Attributes “data members”
   Operations “method members”



2                     www.mahmoud-a.com
            UML – CLASS DIAGRAM
Example :




3                 www.mahmoud-a.com
                  UML – CLASS DIAGRAM
  Class diagrams symbols:
                        Description                                     symbol

Class : represents a person, place, or thing about which the
system will need to capture and store information                    Class name
Attribute: Represents properties that describe the state of an      Attributes list
object Must be named with noun
Method “operation”: Represents the actions or functions that         Methods list
a object can perform Must be named with verb
Association: Represents a relationship between multiple
classes, or a class and itself Must be labeled with verb         association name

Multiplicity: Represents the minimum and maximum times a           *–         –
class instance can be associated with the related class            *-    *    –m
instance                                                            –        m-n


  4                               www.mahmoud-a.com
                   UML – CLASS DIAGRAM
   Class diagrams symbols:
                  Description                                    Symbol
Aggregation: is a weak whole - part
relationship, when an object is part of other           Whole               part
object(s) (is part of)

Composition: is a strong whole – part
relationship, when an object is part of another
object If the container (whole) object is               Whole               part
destroyed the part object is also destroyed

Generalization “ inheritance” : when a class
                                                         super
(subclass) inherits from another class (super
class),meaning that the properties and
operations of the super class are also valid for
objects of the subclass (is – a)                                          sub
   5                                www.mahmoud-a.com
           UML - Class Diagram
                 Customer
                                1


                                                      Rental Invoice



                Rental Item      1..*
                {abstract}
                                                  1           0..1



                                                              1
                                                      Checkout Screen
    DVD Movie   VHS Movie           Video Game




6                             www.mahmoud-a.com
                 UML - Class Diagram
                                             Multiplicity

                      Customer
                                     1                        Simple
       Class                                                Aggregation



      Abstract                                                         Rental Invoice
       Class

                     Rental Item      1..*
                     {abstract}
                                                                 1             0..1
                                             Composition

    Generalization                           (Dependency)                                 Simple
                                                                                         Association

                                                                       Checkout Screen
        DVD Movie    VHS Movie           Video Game




7                                  www.mahmoud-a.com
         UML – CLASS DIAGRAM
Aggregation relationship:
the part may be independent of the whole but the
whole requires the part
An association in which one class belongs to a
collection of classes




8                  www.mahmoud-a.com
           UML – CLASS DIAGRAM
Aggregation Examples:
A room contains a table A table is part of a room, if the
room destroyed the table remains              contains
                                           Room        table

Think about a doctor’s office that has decided to create
health care teams that include doctors, nurses, and
administrative personnel As patients enter the office,
they are assigned to a health care team that cares for
their needs during their visits



9                      www.mahmoud-a.com
           UML – CLASS DIAGRAM
Aggregation Examples:
Order class is part of order details class If the order details
object destroyed the order object remains
a catalogue object is a collection (aggregation) that
consists of many product objects However, any particular
product may appear in more than one catalogue

                           contains
            catalogue                       product




10                      www.mahmoud-a.com
              UML – CLASS DIAGRAM
   Composition relationship :
    Each part object may belong to only one whole object
    at a time
    When the whole object is destroyed, it’s parts also are
    destroyed
    Whole object is responsible for the creation and
    destruction of the parts
In native c++ if your object’s parts are pointer you need to
    destroy it using “delete” keyword, because there is no
    garbage collector! , unlike java, C# and visual basic net

   11                    www.mahmoud-a.com
          UML – CLASS DIAGRAM
Composition examples:
A building contains a room, a room is part of building,
if a building is destroyed the room also destroyed
                                                    contains
                                         building              room
A polygon made of point ,if a polygon is destroyed,
Point will be destroyed with it




12                   www.mahmoud-a.com
          UML – CLASS DIAGRAM
Composition examples:
Think about product group class which is made up of
products, if the product group object deleted the
product object within that group will be deleted too
Imagine such a system including a Generic Report
class A Generic Report is composed of four parts—
Header, Column, Body, and Footer If a report
object is destroyed the parts will be destroyed



13                  www.mahmoud-a.com
          UML – CLASS DIAGRAM
Lab assignment:
   Draw class diagram for aggregation example
   Draw class diagram for composition example




14                   www.mahmoud-a.com
          UML – CLASS DIAGRAM
References:
Systems Analysis & Design with UML, nd Edition
The object primer agile model driven development
with uml




15                www.mahmoud-a.com

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:11
posted:12/12/2012
language:English
pages:15