The Artima Developer Community
Sponsored Link

Design Forum
Composition and aggregation implementation stratagy

4 replies on 1 page. Most recent reply: Jun 1, 2006 7:52 PM by Erik Engbrecht

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Pradeepkumar Patil

Posts: 1
Nickname: sunrise
Registered: Mar, 2006

Composition and aggregation implementation stratagy Posted: Mar 22, 2006 4:53 AM
Reply to this message Reply
Advertisement
If composition is the tight relation between whole and part and aggregation is loose relationship betwen them then what strategy should one apply in designing UMl for effective and efficient implementation?. how can we distinguish them programatically.


Vijay Nathani

Posts: 29
Nickname: vijaynath
Registered: Jan, 2006

Re: Composition and aggregation implementation stratagy Posted: May 3, 2006 1:30 AM
Reply to this message Reply
Programmatically there is no difference between composition, aggregation and association in languages like Java, where the garbage collection is automatic.

Vijay Nathani,
www.geocities.com/vijay_nathani

Shashank D. Jha

Posts: 68
Nickname: shashankd
Registered: May, 2004

Re: Composition and aggregation implementation stratagy Posted: May 24, 2006 12:29 AM
Reply to this message Reply
> If composition is the tight relation between whole and
> part and aggregation is loose relationship betwen them
> then what strategy should one apply in designing UMl for
> effective and efficient implementation?.

If you are using UML for OOA/D, use the relation that exists in the interacting classes/objects. Always remember OOA/D is for modeling real world entities.



>how can we distinguish them programatically.
So for sure there is difference in code as well. In case of composition, the creation and destruction is responsibility of "whole". And the reference of "part" is not passed to interating entities. Example, "floor" (part) of a room (whole) is never shared with another room.

But a wall of a room is shared. So difference in code right?

---------------
Shashank D. Jha
iCMG
e-mail shashank@icmgworld.com

Shashank D. Jha

Posts: 68
Nickname: shashankd
Registered: May, 2004

Re: Composition and aggregation implementation stratagy Posted: May 24, 2006 12:54 AM
Reply to this message Reply
> If composition is the tight relation between whole and
> part and aggregation is loose relationship betwen them
> then what strategy should one apply in designing UMl for
> effective and efficient implementation?.

If you are using UML for OOA/D, use the relation that exists in the interacting classes/objects. Always remember OOA/D is for modeling real world entities.



>how can we distinguish them programatically.
So for sure there is difference in code as well. In case of composition, the creation and destruction is responsibility of "whole". And the reference of "part" is not passed to interating entities. Example, "floor" (part) of a room (whole) is never shared with another room.

But a wall of a room is shared. So difference in code right?

---------------
Shashank D. Jha
iCMG
e-mail shashank@icmgworld.com

Erik Engbrecht

Posts: 210
Nickname: eengbrec
Registered: Apr, 2006

Re: Composition and aggregation implementation stratagy Posted: Jun 1, 2006 7:52 PM
Reply to this message Reply
> Programmatically there is no difference between
> composition, aggregation and association in languages like
> Java, where the garbage collection is automatic.
>
> Vijay Nathani,
> www.geocities.com/vijay_nathani


Not exactly. That's true for immutable objects (like String), but composition is similar to ownership, so it can be very important that other objects aren't modifying an object that is owned by another.

Association, aggregation, and composition may all be directly coded using fields (1..1 and 0..1) or collections (m..n), but the way they should be treated elsewhere in code very differently.

Flat View: This topic has 4 replies on 1 page
Topic: creational patterns Previous Topic   Next Topic Topic: UML Certification

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use