UML Design Basics -part 2-
Introduction To Modeling With Classes
In this article, I will cover what Generalization is, Object Diagrams, Association Vs Generalization, Tips about identifying and specifying valid associations, identifying generalizations, and in general. If you haven’t read Part 1 you can read it here.
A generalization is a taxonomic relationship which used to arrange classes into inheritance hierarchies. look at figure -1-
Generalizations are implemented using the extends keyword
Object Diagram Vs Class Diagram
Object Diagram shows an example of the configuration of objects that may ever exist at a particular point during the execution of the program.
A class Diagram is an abstract representation of all instances of two classes that can ever exist.
Therefore, Object Diagram is generated by a Class Diagram, and Class Diagram can generate an infinite number of Object Diagram.
Class Vs Object
The class name is underlined and precedes by a colon: Human,
Nabeel: Human, is an example of the object named Nabeel of the class Human. And you can omit the class as Nabeel:
Associations Vs Generalization
An association describes a relationship that will exist between instances at runtime.
A generalization describes a relationship between classes in a class diagram.
Tips about :
1. Identifying and specifying valid associations
To figure out if a relationship should exist or not, Ask yourself if one class controls, is connected to, is related to, is a part of, has as parts, is a member of another class.
Be aware, representing actions as if they were associations is a common mistake. DO NOT DO IT
2. Identifying generalizations
There are two ways to identify generalizations: bottom-up and top-down. The top-down approach divides up a complex class, creating new subclasses. whereas the bottom-up approach is several classes that have operations, attributes, or associations in common then you create a superclass for them. Generalizations are implemented using the extends keyword,
a. Use meaningful names in
I. Class name e.g Class Human has an attribute called name, not na or even names. (An attribute should not have a plural name).
II. Method name e.g getJobTittle(), not getjobtittle()
b. Obey the language standards e.g className, not ClassName.
and More… I recommended searching for more.
Creating a good class diagram takes time And because of that Always remember practice makes you perfect. Stay tuned!