Monday 29 August 2016

Class Diagram

 In the system model when to show the classes and their associations between these classes we used class diagram. The class diagram shows the classes, their attributes, operations and the relationship among objects. Objects represent anything in the real word for example a patient, a description, a doctor. Each object class is a definition of one kind of system object. Association between classes shows that there is a link between these classes. Each class has some information about associated class. The class diagram is a static structure of the system.
When developing a model the first step is to identify the essential object, these object is represent as classes.
 The way of representing the classes in the model is to write the class name in rectangular box. And association between classes is represented by drawing a line between classes. To define classes in more detail we add information about attributes (the characteristics of on object) and operations (the function performed by the object) of the classes.
Class diagram look like a semantic data model, semantic data model are used in database design they show the entities and relationship between attribute, and associated attributes. When developing an object-oriented system model we use class diagram to show classes and their relationship.

 Example of class diagram:-

  Loan account class diagram
In the UML attributes and operation are represent by extending the rectangle that represent class. The figure shows that the top of the object class is the name of the object class. Class attribute is in the middle of the section of the rectangle. Operation of the class is represents in the lower section of the rectangle. Loan account will have the attribute account name, date released, loan amount and loan account operation is renew () and extend ().
The class diagram also show how many objects are involved in the association of the classes. How many instances of the object are involved in the association are represented by different characters such as 0 indicate that no instance, 0..1 shows that no instance, or one instance, 1 show exactly one instance, 0..* shows zero or more instance,  * shows zero or more instance, 1..* shows that one or more instance.


                                   1:1 relationship between object

In this example each end is annotated with a 1, it means that there is a 1:1 relationship between objects of these class.  A student can live at one address at the same time and address can belongs to one student.
                    One and many relationship between objects
Generalization:-
                             In generalization learn the characteristics of classes. Different members of these classes have common characteristics. In generalization common information will be maintain in one place only. The generalization is shown as an arrowhead that pointing up to the more general class. The attribute and operation associated with super class are also associated with subclass. The subclass can inherit the attributes and operations from their super class. Subclass can have specific attribute and operation such as student name, address, phone number.  If changes are accepted then do not have to see at all the classes in the system to check that these classes are effect by the changes that are made.


                                 Generalization hierarchy

Aggregation:-
                        In aggregation one object is composed of other object. To show aggregation we use diamond shape next to the class that represent the whole. Object is composed of different part for example study for a course may contain of book, quizzes and recommendation for further reading.




                                The aggregation association


No comments:

Post a Comment