• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

aggregation

 
Rupinder Bains
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, havent been on this site for a while.
Could someone please explain aggregation to me. I don't understand it!!!???!!
Ive been looing through all my books and still has not sunk in. Whats a basic definition for it and what could be a good example for it.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well,
i don't know if this pertains to this forum(as it seems general question to me applicable to C++/C# any object oriented thing) but i'd try to provide u the answer...
aggregation as per the online
Merriam Dictionary,
1 : a group, body, or mass composed of many distinct parts or individuals
2 a : the collecting of units or parts into a mass or whole b : the condition of being so collected
i would say aggregation means "is consist of" term that specifies that "something is consist of something because else the first something doesn't exist " (sorry for little confusing statement. it would sound like recursion)
e.g.
1. CAR is an aggregation of engine, tires,seats etc...
(engine is consist of these things. it can't be there w/o those things. can u think of a car w/o engine??)
engine can be again defined as aggregation of brakes, battery, timing belt u know etc...
2. world is an aggregation of people in it
(world consist of people. if there is no person on earth then its probably just a planet and no one would be refering it to as 'world', right?)

3. JAR file is an aggregation of classes and other possible resources
4. computer is an aggregation of,
CPU, monitor,key board, mouse etc
what i 've observed in most cases is- the top object, which is the aggregation of set of certain other thing, is 'logical' not 'physical'.
CAR i would say is just a word. it becomes a real object when we have put together engine, seats,stearing etc...by definition of a CAR we just percieve that it has to have certain properties like tires, engine etc
hope this helps u.
regards
maulin
 
Bert Bates
author
Sheriff
Posts: 8905
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about this...
Inheritance uses IS-A relationships, for instance: Dog IS-A Canine and Canine IS-A Animal
Aggregation uses HAS-A relationships, for instance: Dog HAS-A collar Car HAS-A Engine.
In Java, aggregation means one class that has, as some of its instance variables, instances of other classes, for example:
class Dog {
Collar c = new Collar( );
}
This is aggregation, Dog HAS-A Collar.
 
Bert Bates
author
Sheriff
Posts: 8905
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a pre-emptive measure, the question asked for a 'basic' explanation and example - sticklers might say this is an over-simplification but I'm sticking to my 'this is a good basic 'answer / example' ' guns.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this context, some programmers may use the word composition (for the 'has a' relationship). This word might be more comfortable for some.
 
Bert Bates
author
Sheriff
Posts: 8905
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a pre-emptive measure, the question asked for a 'basic' explanation and example - sticklers might say this is an over-simplification but I'm sticking to my 'this is a good basic 'answer / example' ' guns.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic