Breaking News

Class Diagram

Class Diagram

In the Unified Modeling Language (UML), a class diagram is a type of static structure diagram that describes the structure of a system by showing the system’s classes, their attributes, and the relationships between the classes.
The class diagram models the data elements in the system,the ways in which they are grouped together and the relationships between them. Class diagrams have at their heart data and behaviour that are unlikely to change frequently and are relatively stable. The object instances will change frequently. The class diagram shows the building blocks of any object-orientated system. Class diagrams depict a static view of the model, or part of the model, describing what attributes and behavior it has rather than detailing the methods for achieving operations. Class diagrams are most useful in illustrating relationships between classes and interfacesGeneralizationsaggregations, and associations are all valuable in reflecting inheritance, composition or usage, and connections respectively.
The diagram below illustrates aggregation relationships between classes. The lighter aggregation indicates that the class “User Account” uses UserAddressBook, but does not necessarily contain an instance of it. The strong, composite aggregations by the other connectors indicate ownership or containment of the source classes by the target classes, for example ContactDetails and ContactGroup values will be contained in UserAddressBook.
img
Classes are composed of three things: a nameattributes, and operations. Below is an example of a class. Class diagrams also display relationships such as containmentinheritanceassociations, and others. Below is an example of an associative relationship:
img
The association relationship is the most common relationship in a class diagram. The association shows the relationship between instances of classes. For example, the class Order is associated with the class Customer. The multiplicity of the association denotes the number of objects that can participate in then relationship. For example, an Order object can be associated to only one customer, but a customer can be associated to many orders.
img
Another common relationship in class diagrams is a generalization. A generalization is used when two classes are similar, but have some differences.
Look at the generalization below:
img
In this example the classes Corporate Customer and Personal Customer have some similarities such as name and address, but each class has some of its own attributes and operations. The class Customer is a general form of both the Corporate Customer and Personal Customer classes. This allows the designers to just use the Customer class for modules and do not require in-depth representation of each type of customer.
When to Use: Class Diagrams
Class diagrams are used in nearly all Object Oriented software designs. Use them to describe the Classes of the system and their relationships to each other.
How to Draw: Class Diagrams
Class diagrams are some of the most difficult UML diagrams to draw. To draw detailed and useful diagrams a person would have to study UML and Object Oriented principles for a long time.
Before drawing a class diagram consider the three different perspectives of the system the diagram will present; conceptualspecification, and implementation. Try not to focus on one perspective and try see how they all work together.
When designing classes consider what attributes and operations it will have. Then try to determine how instances of the classes will interact with each other. These are the very first steps of many in developing a class diagram. However, using just these basic techniques one can develop a complete view of the software system.