Search Results for 'Aggregation'

ATOM Icon

1 POSTS

  1. 2006/05/03 Aggregation by chungki

Aggregation

Aggregation

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. In addition, A Professor could work in more than one department, but a department could not be part of more than one university.

Composition is usually implemented such that an object contains another object. For example, in C++:

class University 
{   ...   
 private:
     Department faculty[20];   ... 
}; 

In aggregation, the object may only contain a reference or pointer to the object:

class Professor; 
class Department 
{ 
  ... 
private: 
  Professor* members[5]; 
  ... 
};

Sometimes aggregation is referred to as composition when the distinction between ordinary composition and aggregation is unimportant.

UML

In UML, composition is depicted as a filled diamond and a solid line. Aggregation is depicted as an open diamond and a solid line. The below image shows compostion, and then aggregation. The code below shows what the source code is likely to look like.

Image:AggregationAndComposition.png

class Car
{
public:    
  virtual ~Car() {delete itsCarb;}  
private:    
  Carburetor* itsCarb
};

class Node
{  
private:    
  vector<Node*> itsNodes;
};

Posted by chungki

2006/05/03 02:14 2006/05/03 02:14
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/207


블로그 이미지

Nice !!!!!!!!

- chungki

Notices

Archives

Authors

  1. chungki

Calendar

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Site Stats

Total hits:
73374
Today:
5
Yesterday:
20