The class diagram is the main building block in object oriented modelling.
In the class diagram these classes are represented with boxes which contain three parts:
A class with three sections.
* The upper part holds the name of the class
* The middle part contains the attributes of the class
* The bottom part gives the methods or operations the class can take or undertake
Visibility
+ Public
- Private
# Protected
~ Package
/ Derived
underline Static
Scope
The UML specifies two types of scope for members:
1. instance
2. and classifier.
In the case of instance members, the scope is a specific instance.
For attributes, it means that its value can vary between instances.
For methods, it means that its invocation affects the instance state,
in other words, affects the instance attributes.
Otherwise, in the classifier member, the scope is the class.
For attributes, it means that its value is equal for all instances.
For methods, it means that its invocation does not affect the instance state.
Classifier members are commonly recognized as "static" in many programming languages.
To indicate that a member has the classifier scope,
its name must be underlined.
Otherwise, as default, the instance scope is considered.
Relationships
1. Instance Level Relationships
A. Association
B. Aggregation
C. Composition
2. Class Level Relationships
A. Generalization
B. Realization
1. A. Association
An Association represents a family of links.
Binary associations (with two ends) are normally represented as a line,
with each end connected to a class box.
Higher order associations can be drawn with more than two ends.
In such cases, the ends are connected to a central diamond.
An association can be named, and the ends of an association can be adorned with role names,
ownership indicators, multiplicity, visibility, and other properties.
There are five different types of association.
Bi-directional and uni-directional associations are the most common ones.
For instance, a flight class is associated with a plane class bi-directionally.
Associations can only be shown on class diagrams. Association represents the static relationship shared among the objects of two classes.
Example: "department offers courses", is an association relation
1. B. Aggregation
Aggregation is a variant of the "has a" or association relationship;
aggregation is more specific than association.
It is an association that represents a part-whole or part-of relationship.
As a type of association,
an aggregation can be named and have the same adornments that an association can.
However, an aggregation may not involve more than two classes.
Aggregation can occur when a class is a collection or container of other classes,
but where the contained classes do not have a strong life cycle dependency on the container
—essentially, if the container is destroyed, its contents are not.
In UML, it is graphically represented as a hollow diamond shape on
the containing class end of the tree of lines
that connect contained class(es) to the containing class.
1. C. Composition
Composition is a stronger variant of the "owns a" or association relationship;
composition is more specific than aggregation.
Composition usually has a strong life cycle dependency
between instances of the container class and instances of the contained class(es):
If the container is destroyed, normally every instance that it contains is destroyed as well.
Note that a part can (where allowed) be removed from a composite before the composite is deleted, and thus not be deleted as part of the
composite.
The UML graphical representation of a composition relationship
is a filled diamond shape on the containing class end of the tree of lines that connect contained class(es) to the containing class.
2. A. Generalization
The Generalization relationship indicates that one of the two related classes (the subtype)
is considered to be a specialized form of the other (the super type) and supertype
is considered as 'Generalization' of subtype.
In practice, this means that any instance of the subtype is also an instance of the supertype.
An exemplary tree of generalizations of this form is found in binomial nomenclature:
human beings are a subtype of simian,
which are a subtype of mammal, and so on.
The relationship is most easily understood by the phrase 'an A is a B'
(a human is a mammal, a mammal is an animal).
The UML graphical representation of a Generalization
is a hollow triangle shape on the supertype end of the line (or tree of lines)
that connects it to one or more subtypes.
The generalization relationship is also known as the inheritance or "is a" relationship.
The supertype in the generalization relationship is also known as the "parent", superclass, base class, or base type.
The subtype in the specialization relationship is also known as the "child", subclass, derived class, derived type, inheriting class, or
inheriting type.
Note that this relationship bears no resemblance to the biological parent/child relationship:
the use of these terms is extremely common, but can be misleading.
* Generalization-Specialization relationship
A is a type of B
E. g. "an oak is a type of tree", "an automobile is a type of vehicle"
General Relationship
1. Dependency
Dependency is a weaker form of relationship
which indicates that one class depends on another because it uses it at some point of time. Dependency exists if a class is a parameter
variable or local variable of a method of another class.
2. Multiplicity
The association relationship indicates that (at least) one of the two related classes makes reference to the other.
In contrast with the generalization relationship,
this is most easily understood through the phrase 'A has a B'
(a mother cat has kittens, kittens have a mother cat).
The UML representation of an association
is a line with an optional arrowhead indicating the role of the object(s) in the relationship,
and an optional notation at each end indicating the multiplicity of instances of that entity
(the number of objects that participate in the association).
0..1 No instances, or one instance (optional, may)
1 Exactly one instance
0..* or * Zero or more instances
1..* One or more instances (at least one)
Sumber:
* http://en.wikipedia.org/wiki/
* http://en.wikipedia.org/wiki/
* http://en.wikipedia.org/wiki/
* http://en.wikipedia.org/wiki/
* http://en.wikipedia.org/wiki/
* http://en.wikipedia.org/wiki/
* http://en.wikipedia.org/wiki/