What is aggregation and composition of objects?What is the diff between monolithic and composite object?

Showing Answers 1 - 5 of 5 Answers

pranabj

  • Apr 5th, 2006
 

Suppose, you have a class named UserInformation . And with that class you are having a object instance named UserContactInfo

Class UserInformation {

UserContactInfo userContactInfo ;

}

This leads to aggregation. The UserContactInfo object is aggreated within UserInformation class. Both the classes have individual identity.

Now , suppose we have a class named Rectangle . And within that class you have Class Point as a object.

Class Rectangle {

Point point ;

}

Now , rectangle is a composition of points. Point class doesn't have any individual important . It is point that makes a rectangle . This is known as composition.

Hope it makes clear.

  Was this answer useful?  Yes

rajagobals

  • Sep 14th, 2006
 

Aggregation differs from ordinary composition in that it does not imply ownership. In composition, when the owning object is destroyed, so are the contained objects. In aggregation, this is not necessarily true.

For example, a university owns various departments (e.g., chemistry) , and each department has a number of professors. If the university closes, the departments will no longer exist, but the professors in those departments will. Therefore, a University can be seen as a composition of departments, whereas departments have an aggregation of professors.

talktoatish

  • Aug 19th, 2009
 

A monolithic object is an object that has no externally-discernible structure.
Said another way, a monolithic object does not appear to have been constructed
from two or more other objects.

Specifically, a monolithic object can only be treated as a cohesive whole.
Those outside of a monolithic object cannot directly interact with any (real or
imagined) objects within the monolithic object.


A radio button in a graphical user interface (GUI) is an example of a
monolithic object. Composite objects are objects that have an
externally-discernible structure, and the structure can be addressed via the
public interface of the composite object. The objects that comprise a composite
object are referred to as component objects.


Composite objects meet one or both of the following criteria:
* the state of
a composite object is directly affected by the presence or absence of one or
more of its component objects, and/or
* the component objects can be directly
referenced via the public interface of their corresponding composite object.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions