Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


GDB Dated: Feb 08, 13

Dear Students,

 

Below is the topic for GDB. You are required to submit your discussion in the mentioned time and duration. Please make sure that your reply should be precise and to the point.

GDB will remain open for two consecutive days (48 hours). For this you have choice to post your comments from 14th February to 15th February, 2013.

 

Topic is as follows:

 Suppose we have implemented a scenario and we used aggregation in it, after some time we realize that use of aggregation is not a correct choice, now we want to use composition instead of aggregation. Can we replace composition with aggregation? At which phase(s) these changes are required?  Justify your answer with solid reasons. 

 
A concise, coherent and to the point comment is preferred over lengthy comment having irrelevant details. Your comment must not be more than 5-6 lines. Comments, posted on regular Lesson's MDB or sent through email will NOT be considered in any case. Any request about such an acceptance will not be catered.

Views: 1553

Replies to This Discussion

Please Discuss here about this GDB.Thanks

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.

i think the main difference is we use pointer in aggregation but we do not use it in composition

you may be right 

Actually composition is implemented by creating object of one class in other class but in aggregation we just put then reference of a class in another by this if we destroy master class so then other class remain save. If we want to change the aggregation relationship into composition then we have to put the object in the master class instead of reference.

@Ash......    But don't you think....!this approch will lead us to the  dangling points problem in case of destroying the master class when we use aggregation.(means pointers are pointing some thing that has been deleted)

And by the way pointer are just address reference carrier nothing else..then how do we change the aggregation with composition....

actually hum aggregation main jonsa pointer use karain gay wo master class k object ka nai hoga but dosri class k object ka hoga is liye master class destroy honay say usay faraq nai paray ga for example aik class hai room and aik class hai chair ab agar chair room main hogi then it is aggregation so chair class ka pointer hum room class main rakh dain gay so agar room destroy b ho gaye so hum chair kisi or room main b rakh saktay hain is say chair k object ko faraq nai paray ga

but  our  goal is to give reason weather we replace aggregation by composition or not.

And per you point we can not replace aggregation with composition, if you do definatly there will be dangling points problem will be their.

So what should we do to avoid dangling point problem and easily can replace aggregation with composition.

sir nay pocha hai k kya hum change kar saktay hain han hum change kar saktay hain or change karnay k liye pointer ki jaga hamain object declare karna hoga

hmmm

 there is intrinsic relationship between two objects then we have either Composition or Aggregation between these two objects .as Aggregation also refers to collection of objects, but in case of Aggregation composing objects have their independent existence as well.Aggregation is implemented by placing the reference (pointer array) of the aggregating class objects in the class where they are aggregated.


composition is implemented by creating object of one class in other class but in aggregation we just put then reference of a class in another by this if we destroy master class so then other class remain save. If we want to change the aggregation relationship into composition then we have to put the object in the master class instead of reference.


An Association

is a channel between classes through which messages can be sent. As sending messages translates to calling methods in Java, Associations are typically (but not necessarily) implemented by references.
An Aggregation

is an Association which denotes an "is part of" relationship. Unfortunately, the definition of this relationship is quite lax, so basically everyone is using his own interpretation. The only definitive (?) property is that in an instance graph, aggregations are not allowed to be circular - that is, an object can not be "a part of itself". (or) When building new classes from existing classes using aggregation, a composite object built from other constituent objects that are its parts.Java supports aggregation of objects by reference,since objects can't contain other objects explicitly.

A Composition

adds a lifetime responsibility to Aggregation. In a garbage collected language like Java it basically means that the whole has the responsibility of preventing the garbage collector to prematurely collect the part - for example by holding a reference to it. (In a language like C++, where you need to explicitely destroy objects, Composition is a much more important concept.) Only one whole at a time can have a composition relationship to a part, but that relationship doesn't need to last for the whole lifetime of the objects - with other words, lifetime responsibility can be handed around.

Aggregation and Composition 

Sometimes an object is made up of other objects. For example, an airplane is made up of a fuselage, wings, engines, landing gear, flaps, and so on. A delivery shipment contains one or more packages. A team consists of two or more employees. These are all examples of the concept of aggregation, which represents “is part of” relationships. An engine is part of a plane, a package is part of a shipment, and an employee is part of a team. Aggregation is a specialization of association, specifying a whole-part relationship between two objects. Composition is a stronger form of aggregation where the whole and parts have coincident lifetimes, and it is very common for the whole to manage the lifecycle of its parts. From a stylistic point of view, because aggregation and composition are both specializations of association the guidelines for associations apply.



Attachments:

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service