Saturday, June 30, 2012

Class Diagram for Software Design


INTRODUCTION
 CLASS DIAGRAM
       A class diagram shows the existence of classes and their relationships in the logical view of a system
       UML modeling elements in class diagrams are:
      Classes, their structure and behavior.
      relationships components among the classes like association, aggregation, composition, dependency and inheritance
      Multiplicity and navigation indicators
      Role names or labels.
Basic two types  of classes
Concrete classes
       A concrete class is a class that is instantiable;  that is it can have different instances.
       Only concrete classes may be leaf classes in the inheritance tree.
Abstract classes
        is a class that has no direct instance but whose descendants classes have direct instances.
       can define the protocol for an operation without supplying a corresponding method we call this as an abstract operation.
operation defines the form of operation, for which each concrete subclass should provide its own implementation

Types of Relationships between classes
       Association
       Aggregation
       Composition
       Inheritance
       Dependency
       Instantiation


ASSOCIATION
      These are the most general type of relationship:
       It denotes a semantic  connection between two classes
        It shows BI directional connection between two classes
       It is a weak coupling as associated classes remain somewhat independent of each other
       Example:




AGGREGATION
      This  is a special type of association
       The association with label “contains” or “is part of” is an aggregation  è  represents “has a “ relationship
       It is used when one object logically/physically contains other
       The container is called as aggregate 
       It has a diamond at its end
       The components of aggregate can be shared with others
       It expresses a whole - part relationships, like …


     COMPOSITION
      This  is a strong form of aggregation 
       It expresses the stronger coupling between the classes
       The owner is explicitly responsible for creation and deletion of the part
       Any deletion of whole is considered to cascade its part
        The aggregate has a filled diamond at its end

INHERITANCE
       The inheritance relationship helps in managing the complexity by ordering objects within trees of classes with increasing levels of abstraction. Notation used is solid line with arrowhead, shown below.
       Generalization and specialization are points of view that are based on inheritance hierarchies.


DEPENDENCY
       Dependency is semantic connection between dependent and independent model elements.
       This association is unidirectional and is shown with dotted arrowhead line.
       In the following example it shows the dependency relationship between client and server.
       The client avails services provided by server so it should have semantic knowledge of server.
       The server need not know about client.



INSTANTATION
      This relationship is defined between parameterized class and actual class.
       Parameterized class is also referred as generic class.
       A parameterized class can’t have instances unless we first instantiated it
                Example:




      Cardinality or Multiplicity
      Definition: Number of instances of each class involved in the dialogue is specified by cardinality.


       Common multiplicity values:
       Symbol                 Meaning
       1                                              One and only one
       0..1                                         Zero or one
       M…N                     From M to N (natural integer)
       0..*                                        From zero to any positive integer
       1..*                                        From one to any positive integer
       Also thought can be given about navigability to every applicable relationship.

 source:Arun Timalishna(ioe lecturer)

1 comment:

  1. Thanks for the great explanation. I found more examples and information on creately diagram community.

    ReplyDelete