Skip to main content

UML Class Diagram

The UML Class diagram is used to visually describe the problem domain in terms of types of object (classes) associated with each other in different ways.

Association

The most abstract way to describe static relationship between classes is using the ‘Association’ link, which simply states that there is some kind of a link or a dependency between two classes or more.
image
Weak Association
ClassA may be linked to ClassB in order to show that one of it methods includes parameter of ClassB instance, or returns instance of ClassB.
image
Strong Association
ClassA may also be linked to ClassB in order to show that it holds reference to ClassB instance.
image

Aggregation (Shared Association)

In cases where there’s a part-of relationship between ClassA (whole) and ClassB (part), we can be more specific and use the aggregation link instead of the association link, taking special notice that ClassB can also be aggregated by other classes in the application (therefore aggregation is also known as shared association).
image
So basically, the aggregation link doesn’t state in any way that ClassA owns ClassB nor that there is a parent-child relationship (when parent deleted all its child’s are being deleted as a result) between the two. Actually, quite the opposite! The aggregation link usually used to stress the point that ClassA is not the exclusive container of ClassB, as in fact ClassB has another container.
image
Aggregation v.s. Association
The association link can replace the aggregation link in every situation, while aggregation cannot replace association in situations were there is only a ‘weak link’ between the classes, i.e. ClassA has method/s that contain parameter of ClassB but ClassA doesn’t hold reference to ClassB instance.
Martin Fowler suggest that the aggregation link should not be used at all because it has no added value and it disturb consistency, Quoting Jim Rumbaugh "Think of it as a modeling placebo".

Composition (Not-Shared Association)

In cases where in addition to the part-of relationship between ClassA and ClassB - there’s a strong life cycle dependency between the two, meaning that when ClassA is deleted then ClassB is also deleted as a result, we should be more specific and use the composition link instead of the aggregation link or the association link.
image
The composition link shows that a class (container, whole) has exclusive ownership over other class/s (part’s), meaning that the container object and it’s parts constitute a parent-child/s relationship. So the part's maybe used by other objects in the application, but those should respect the fact that once the parts container is deleted (or disposed in GC based environment) they have deleted/disposed objects in there hand.

Popular posts from this blog

A KING WHO WAS POPULAL AMONG HIS PEOPLE (King Birendra)

King of Nepal Reign 31 January 1972 –1 June 2001 Predecessor Mahendra Successor Dipendra Consort Aishwarya Rajya Laxmi Devi Shah Father King Mahendra Bir Bikram Shah Dev Mother Indra Rajya Laxmi Born 28 December 1945 Kathmandu, Nepal Died 1 June 2001 (aged 55) Kathmandu, Nepal Religion Hinduism Birendra and Aishwaraya had three children. Prince Dipendra (27 June 1971 – 4 June 2001) Princess Shruti (15 October 1976 – 1 June 2001) Prince Nirajan (6 November 1977–1 June 2001) Known As: A soft-spoken man with glasses and a mustacheKing Birendra was 10th in his line to rule Nepal and considered by some to be an incarnation of the Hindu god Vishnu.On formal occasions, the king was known for stilted speeches full of jargon that did not generate much inspiration.He was more at ease and best liked for listening closely to the problems of common people, especially poor villagers in a country that is among the poorest in the world with ...

A KING WHO WAS FAMOUS (His Majesty King Mahendra)

King Mahendra  Born > 11 June 1920 Father > King Tribhuvan Bir Bikram Shah Married To >  Indra Rajya Laxmi, daughter of General Hari Shamsher Rana in 1940 . Three sons >  Birendra,  Gyanendra, and Dhirendra Three daughters >Shanti, Sharada and Shobha. After Queen Indra died in 1950. In 1952 Mahendra married Indra's sister Ratna Rajya Lakshmi Devi. Crowned > May 2, 1956 Mahendra was made a British Field Marshal in 1960. Mahendra implemented a land reform policy, which provided land to many landless people. The Mahendra Highway (also called East-West Highway) that runs along the entire Terai belt in southern Nepal was constructed during his reign. He played a key role in making Nepal a member of the United Nations. Mahendra died with a heart attack while hunting in Chitwan with Tiger Tops Hotel. It is believed  that his death was a conspiracy of CIA as John Coapman who was also proprietor of  Chitwan with Tiger Tops Hotel was ...

Quest Software’s Unicode (UTF-8)

Please make note of the following caveats Toad for Oracle supports any single-byte character set. Enabling UTF-8 does not automatically cause issues with Toad. The use of double-byte or multi-byte character does not automatically result in issues with Toad, provided that the Oracle database Client/Server configuration settings are in synch. For instance, Toad for Oracle is used extensively in Korea and it works well. Issues can arise with certain combinations of the Oracle client NLS settings and Windows regional settings. However, they seem to occur only when inserting or updating data (there are some scenarios in which data retrieval can cause issues). This makes it crucial for the database, client and OS to be in synch with any internationalization settings. In addition, when using UTF-8 data in the editor or a grid, a font that supports the desired characters must be selected as the default font. Mono-space fonts (also known as fixed-width or non-proportional) will not support...