Composition and Aggregation

hey guys
I have read the previous posts about composition and aggregation. And here is what i have got.
Composition: life time of objects got to be the same. For example there is a composition between carframe and a car. If the car gets destroyed the carframe woulod also get destroyed.
Aggregation: Life times of the objects are not the same, one oject can live even after the other object has been destroyed.
But i seem to get all these things in theory, but when it comes to coding am not able to translate these theories. To be particular i would want someone to help with me how these relationship can be coded
Thanks
K

Consider the following example :
Car has an engine, chairs, wheel, etc. it is clear
that this is composition, because "Car" is composed
of engine, chairs wheel and so on. but think about
what happens if you want to destroy the car, but
reuse its engine, thing that frequently happen when
you get your car smashed (didn't happen to be thanks
god). Anyway you destroy the car, but it parts stay
alive. so the "composed" objects lifetime can exceed
the "composer" object lifetime.
I think of composition and aggregation in the
following way :
if there is no meaning to the object without its
parts (parts of which it is
composed) then it is composition. if there is any
meaning for the object without its parts (like empty
paragraph (without words) in text, which can be left
empty till the wrighter have something to write in)
well, then it is aggregation.sometimes a car could be smashed and the engine would still be running, junkyard sells tires from wracked cars... all tha, however, has nothing to do with composition or aggration.
composition is a strong form of ownership, a car probablly needs to have an engine, some tirs etc in order to be sold as a car, so the engin, tirs are usually composed as composition. life time of them begins when the car is instantiated and until the instance vanishes. when a car is smashed or totaled, it is merely a state of the car instnace, like a flat tire, the car instnace still exists, so a running engine on a totaled car is ok.
usually if your object has a field referencing an object, that object is a composition, even the creation occurs earlier that the creation of the instance itself, such a case would be a DI: dependency injection. the destruction of an instance is a bit beyond the control of the composing instaance, that however dosnt matter, once the field loses the reference, we can think of it as the end of the life of the composed object. this is a bit different from C++ which allows you to invoke the destructor of the composed object. another difference is that you can have local objects, java objects all live in the heap area, no local objects.

Similar Messages

  • Composition and aggregation implementation

    how to write composition and aggregation implementation in java ?
    As both of them contains another objects, how do we code to differentiate them ? I'm worried about implementation.
    Are they same in implementation-wise but differ in concept-wise ?

    user575089 wrote:
    how to write composition and aggregation implementation in java ?
    As both of them contains another objects, how do we code to differentiate them ? I'm worried about implementation.
    Are they same in implementation-wise but differ in concept-wise ?I really think you nailed it and there is nothing more for me to add.

  • Composite and aggregation code example - is this correct

    after reading all the aggregation and composition of this forum threads, i would like to know whether this is the corect understading in java implmentation of composite and aggregation.
    example of aggregation
    public class Money{}
    public class Wallet {
    private Money money;
    public Wallet(Money money) {
    this.money = money;
    example of composite
    public class Heart {}
    public class Human {
    private Heart heart;
    private Human() {
    heart = new Heart();
    the aggregation implementation is based on the idea " The instance of aggregated class can be shared by many other classes. While those classes are deleted, the instance of aggreated class won't be deleted."
    hence, i create money object outside the wallet, the passed the money into the wallet to make them "has a" relationship.
    the composite implementation is based on the idea " the instance of composited class can only be used by one other class. While that class is deleted. The composited class will also be deleted."
    hence, the creattion of heart is done by the human constructor it self.
    1. is this the only ways to do the implementation for composite and aggregation?
    2. is there other implementations for aggregation, the money class is constructed inside the wallet class?
    3. is there other implementations for composition, the heart class is constructed outside the human class?
    thank you very much!

    Your abstractions are quite good.
    1. is this the only ways to do the implementation for composite and aggregation?Broadly speaking yes, there are as some subtle variations, but you examples illustrate the key distinction.
    2. is there other implementations for aggregation, the money class is constructed inside the wallet class?Yes, in practice you should also have methods to add and remove from an abstraction, so Wallet should have Wallet.add(Money) and Wallet.remove(Money) methods. You should also consider multiplicity, which may require that you use Qualified Classes and/or Associative Classes to implment an aggregation.
    No, you should not construct the Money inside the Wallet. If you find you want to do this you should consider changing to a Composite.
    3. is there other implementations for composition, the heart class is constructed outside the human class?Yes, it is usual to pass a this from the Composite (Human) to the part (Heart) when you construct it because Composition is implicitly a bi-directional relationship.
    No the part of a composite should not be constructed outside the composite.

  • Difference between composition and aggregation

    Could anyone explain to me the difference between aggregation and composition. I remember studying some but cant recall it.

    though this question has been put in for quite some time now but being of an interesting nature I would like to answer that still.
    As far as I know aggregation is a simple has a relationship
    e.g A student has books.
    A professor has students.
    Naome has a Car.
    Now you cannot say that : -
    A student is composed of books.
    However in composition the relationship is has a, is composed of .
    So A university is composed of many schools.
    A car is composed of parts.
    A housed is composed of windows.
    The second type of relationship is compositiob while first one is aggregation.

  • LVOOP composition and delegates

    LVOOP doesn't support multiple inheritance, deciding instead to favour composition and aggregation (which happens to coincide with the "Gang of four" IIRC).
    When we are working with composition (An object contains sub-objects for some or all of its functionality) when do we start to talk about delegates?  At what stage does a sub-object of any of my given classes become a delegate?  Are there any guidelines as to what is a delegate and what not?
    If I have a Class A which exposes Methods 1,2,3,4 and 5 to the outside world I may choose to use Class B (or a derivative class) to implement Methods 3,4,and 5.  When does this class become a delegate?
    Shane.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

    Nickerbocker wrote:
    Could you explain more what about LVOOP not supporting multiple inheritance and why that is keeping you from accomplishing something?
    The way you describe delegation sounds right to me.  I do Composition and Delegation all the time in my LVOOP designs.  It is good to be on the same page when discussing what we call these patterns.  That being said, I read design pattern books to get my OOP juices flowing.  Not necessarily to look for exact solutions because they tend to be too generatlized to be directly applicable to a lot of real world problems.
    The lack of multiple inheritance is not keeping me from accomplishing anything at all.  I fully agree with AQ that anything which can be done with multiple inheritance can also be done with compositing.  I was just a little unclear as to when an object becones a delegate.
    Shane.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • UML: Composition and its implementation aspect?

    UML: Composition and its implementation aspect using a Nested Class (Is it always or depends or is there another equivalent way?)
    1. I read this thread: http://forum.java.sun.com/thread.jsp?forum=425&thread=306033&start=0&range=15&hilite=false&q=
    2. Now, basically I want to understand:
    a. If a nested class is NECESSARILY a form of composition? Or it depends on the meaning of the presented code and/or the meaning of the requirement?
    b. When there is a composition, should we ALWAYS model it using a nested class and in which case/scenario/example, the choice of nested class is justifiable AND mandatory?
    c. Is there any example that the Composition can be implemented by nested class (es) as well as non-nested class? (Equivalent way)
    d. Depends on c., if there is a choice between a nested class and non-nested class? Which is better and from what angle?
    3. 1M Thanks.

    When you say nested class, I interpret that as a Java inner class.
    If that's true, then I don't think that composition is always modeled as an inner class. It's more likely to be a simple private data member that's a public class type.
    I usually see composition as a non-nested class. In his "UML Distilled", Martin Fowler says aggregation is the part-of relationship. Composition is a stronger variety of aggregation, where the part object may belong to only one whole and lives and dies with the whole.
    So if you have a Polygon class that has a Collection of Points as member data, that's composition. No inner classes in sight. - MOD

  • Composite and S-video

    Does the 2009 mini support composite and/or s-video. If so, which cable would work best?

    And no thnks to APPL for this terrible decision, worse for not making it clear up front!
    It clearly states in the product description on their website what video options it supports.
    We are now in the HDTV age so it is understandable that apple are not supporting legacy devices.
    The same thing happened when apple stopped using their proprietary monitor connections and then again when they no longer supported ADC connections.
    Technology moves forward all the time it a fact of tech life but unfortunately although this suits the majority there will always be a few that are disappointed.

  • WebI issue with hierarchy display and aggregation

    Trying to wrangle what looks like a defect in WebI's handling of hierarchy display and aggregation. We just completed an update cycle and are running BOBJ 4.1 SP4.
    The hierarchy is a standard FM Commitment Item hierarchy in which both the nodes and leaves are Commitment Items (i.e. it uses InfoObject nodes, not text nodes). An example of one of these nodes looks like this in BW:
    Cmmt_Item A - Node
        Cmmt_Item B - Leaf
        Cmmt_Item C - Leaf
    Let's pretend Commitment Item A has $50 posted to it, B has $20 and C has $30. Analysis for OLAP handles this by adding a virtual leaf line to distinguish postings that are on the parent node like so:
    Cmmt_Item A - Node       $100
        Cmmt_Item A - Leaf    $50
        Cmmt_Item B - Leaf    $20
        Cmmt_Item C - Leaf    $30
    So you see both the total for the node ($100) and a line for each Commitment Items with KFs posted to them. Our users like this. They can easily see the aggregation and the breakdown.
    WebI, on the other hand, will display it like this:
    Cmmt_Item A - Node       $150
        Cmmt_Item B - Leaf    $20
        Cmmt_Item C - Leaf    $30
    It doesn't create a separate line for the value of the parent node, but it does add it's value into the aggregate. Twice. Modifying the table with the 'avoid duplicate row aggregation' checkbox yields output like this:
    Cmmt_Item A - Node       $100
    Cmmt_Item A - Node        $50
        Cmmt_Item B - Leaf    $20
        Cmmt_Item C - Leaf    $30
    We're about halfway there. While the top row now shows the correct aggregation and it creates a new line to show the distinct amount on the parent node, that new line appears on the same level as the parent. It's no longer clear that there's an aggregate and a breakdown. And attempting to expand or contract a node will now crash the report with one of those 'Error 16' messages.
    Has anyone encountered this issue with hierarchies in WebI? This report was built from scratch in 4.1, so I'm not sure if this affects older versions or not. Or if it would affect any hierarchy that uses InfoObject nodes instead of text nodes.

    Without a fix, the simplest workaround I can think of would be to restructure the hierarchy. It can't use postable nodes, so Cmmt_Item A  - Node from my example would need to be converted into a text node and the postable characteristic added as a child on the same level as the B and C leaves.
    This looks like it would affect anyone using hierarchies with postable nodes in a WebI report.
    Another oddity in WebI's behavior here - even though the postable nodes show incorrect sums the sum at the root node is correct. So extending my examples from the original post:
    Root Node                    $100
        Cmmt_Item A - Node       $150
            Cmmt_Item B - Leaf    $20
            Cmmt_Item C - Leaf    $30

  • Report with non aggregated and aggregated columns from different facts.

    Hi,
    We have got requirement as follows,
    1) We have two dimension tables, and two fact(Fact1 and Fact2) table in physical.
    2) In BMM we have made hierarchies for both dimensions, and are joins both logical fact table.
    3)In fact1, we are having three measures of which we have made two as aggregation sum, and one is non aggregated(It contains character).
    4)Fact2 have two measures, both are aggregation as sum.
    5)Now here the problem arises, we want to make a report with some columns from dim and non aggrgated column from fact1 and and aggregated column fact2
    How to resolve the above issue.
    Regards,
    Ankit

    As suggested you really want to move your none-aggregated fact attributes to a logical dimension (using the same physical table as the logical fact). Map this in the BMM layer as a snowflake, Place a hierarchy on this dimension with (at minimum) Total -> Detail levels, then on the other fact table you want to include in the report, set the content level on your other fact measures to the 'Total' level for your new logical Dim and it will allow them to be present in the same report.

  • What are the major differences between a Access Switch and Aggregation Switch w.r.t Carrier Ethernet domain?

    In a Carrier Ethernet domain,Could someone please help me understand what's the basic difference between Access Switch and Aggregation Switch both in terms of s/w and h/w functionalities. MEF deals OAM,CFM, EVC provisioning only at the access edge switches. Do we need to repeat all these at the aggregation level? or  is it just used for routing purpose? Do we have a separate Fault Management at the aggregation level?

    Duplicate posts.  :P
    Go here:  https://supportforums.cisco.com/discussion/12137156/what-are-major-differences-between-access-switch-and-aggregation-switch-wrt

  • Upload text file to oracle table with checking and aggregation

    Hi Friends,
    I am new to ODI.  I have encountered a problem which is specific to ODI 11G (11.1.1.6.3) to upload text file to oracle table with checking and aggregation.  Would you please teach me how to implement the following requirement in ODI 11G?
    Input text file a:
    staffCode, staffCat, status, data
    input text file b:
    staffCodeStart, staffCodeEnd, staffCat
    temp output oracle table c:
    staffCat, data
    output oracle table d:
    staffCat, data
    order:
    a.staffCode, a.staffCat, a.status
    filter:
    a.status = ‘active’
    join:
    a left outerjoin b on a.staffCode between b.staffCodeStart and b.staffCodeEnd
    insert temp table c:
    c.staffCat = if b.staffCat is not null then b.staffCat else a.staffCat
    c.data = a.data
    insert table d:
    if c.staffCat between 99 and 1000 then d.staffCat = c.staffCat, d.data = sum(c.data)
    else d.staffCat = c.staffCat, d.data = LAST(c.data)
    Any help on fixing this is highly appreciated. Thanks!!
    Thanks,
    Chris

    Dear Santy,
    Many thanks for your prompt reply.  May I have more information about the LAST or SUM step?
    I was successful to create and run the following interfaces p and q
    1. Drag text file a to a newly created interface panel p
    2. Filter text file a : a.status = ‘active’
    3. Lookup text file a to text file b : a.staffCode between b.staffCodeStart and b.staffCodeEnd
    4. Drag oracle temp table c to interface panel p
    5. Set c.staffCat : CASE WHEN b.staffCat IS NULL THEN a.staffCat ELSE b.staffCat END
    6. Set c.data : a.data
    7. Drag oracle temp table c to a newly created interface panel q
    8. Drag oracle table d to interface panel q
    9. Set UK to d.staffCat
    10. Set Distinct Rows to table d
    11. Set d.staffCat = c.staffCat
    12. Set d.data = SUM(c.data)
    However, the interface q should be more than that:
    If c.staffCat is between 99 and 1000, then d.data = the last record c.data; else d.data = sum(c.data)
    Would you please teach me how to do the LAST or SUM steps?  Moreover, can interface p and interface q be combined to one interface and do not use the temp table c?  Millions thanks!
    Regards,
    Chris

  • I am considering buying a new MAC laptop to run LOGIC for composition and band live/recording, but which one is best as I do not want to spend too much money? Does it have a line in and how do you monitor sound? Will I need adaptors and a interface?

    Can anybody help?
    I am considering buying a new MAC laptop to run LOGIC for composition and band live/recording, but which one is best as I do not want to spend too much money?
    Does it have a line in and how do you monitor sound?
    Will I need adaptors and an interface?
    Also, I am guessing as Logic only runs on MAC surely then they would not the best spec to recommend to run it?
    I see all the upgrades as additional memory or a faster process?
    Is a retina screen necessary, and why flash based storage against a 1TB hard drive, and a i5 instead of an i7
    The main reason for this purchase is to play live and use backing tracks and record found sounds and make creative songs.
    I hope you can provide some valuable feedback, as I am a longtime MAC user and see upgrades and changes happen regularly but the most important thing is the songs not the equipment.
    I have £500 already and willing to add another 500 to 700 pounds, then software extra.

    Can anybody help?
    I am considering buying a new MAC laptop to run LOGIC for composition and band live/recording, but which one is best as I do not want to spend too much money?
    Does it have a line in and how do you monitor sound?
    Will I need adaptors and an interface?
    Also, I am guessing as Logic only runs on MAC surely then they would not the best spec to recommend to run it?
    I see all the upgrades as additional memory or a faster process?
    Is a retina screen necessary, and why flash based storage against a 1TB hard drive, and a i5 instead of an i7
    The main reason for this purchase is to play live and use backing tracks and record found sounds and make creative songs.
    I hope you can provide some valuable feedback, as I am a longtime MAC user and see upgrades and changes happen regularly but the most important thing is the songs not the equipment.
    I have £500 already and willing to add another 500 to 700 pounds, then software extra.

  • "Validation" enabled for the composite and my testsuites are not working

    I have posted the below issue in Test suite in JDEV - Studio Edition Version 11.1.1.2.0 But I felt that this is the right forum, so posting this again here:
    I have mediator calling bpel. Mediator is exposed as web service. Whenever I run the service using "Test" button on EM with validation turned on
    then it works and the process will be completed.
    But I have initiate xml in the test suites. I select "UnitTests" and select my test case xml that was associated to "Initiate Message for operation",
    I see that the process is still in the "Running" state. I put in exactly the same values as I use for testing the service from EM.
    Did anybody face this issue? This happens only when we turn the validation to "Enabled" in EM.
    I have "Validation" enabled for the composite and my testsuites are not working. When I test using unit tests, I am only seeing "Running" status of the processes and these are not getting completed.

    Hello there, RevDebMN.
    The following Knowledge Base article is always a great fallback article for troubleshooting Mail issues:
    OS X Mail: Troubleshooting sending and receiving email messages
    http://support.apple.com/kb/ts3276
    Particularly useful, in your case:
    Mail Connection Doctor shows one or more red dots () in the account Status column
    Check your Incoming IMAP or POP and Outgoing SMTP email account settings
    Use Apple's online Mail Setup Assistant to discover what the correct settings should be for both your Incoming (IMAP or POP) and Outgoing SMTP email servers. If your email service provider is not listed in the Mail Setup Assistant, visit your email service provider's website or contact their support staff to get the correct settings. You can use this "cheat sheet" when asking your email service provider about the settings you need.
    After you have the correct email service provider settings, make sure Mail is configured properly.
    Click here if your Incoming and Outgoing email account settings are correct, but the issue persists
    What alert message is shown in the Mail Connection Doctor "Details" column affected account?
    Click here if a "Could not connect to this (server type) server…" message appears
    Click here if a "Trying to log in to this (email server provider name) account failed…" message or any other error message appears
    If the issue persists, then you'll want to remove the account and then add it again using this article:
    Mail (Mountain Lion): Remove accounts
    http://support.apple.com/kb/PH11794
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • Use of filters and aggregations based on hierarchy nodes in an update rule

    Hello,
    I need to calculate some indicators from a ODS (BW 3.5) that contain raw data to another one that will contain indicators. These figures are the results of the use of filters and aggregations based on hierarchy nodes (for example: all sales accounts under a node).
    In fact, this is typically a query but I want to store these figures, so I need
    I understood I have to use a start routine. I never did that before.
    Could you provide me with easy-to-understand-for-newbies examples of:
    - filtering data based on the value of an infoobject (value must be empty, for example)
    - filtering and aggregation of data based on the appartenance to hierarchy nodes (all sales figures, ....)
    - aggregation of the key figures based on different characteristics after filtering of these
    Well, I am asking a lot ...
    Thank you very much
    Thomas

    Please go through the following link to learn more on aggregates:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e55aaca6-0301-0010-928e-af44060bda32
    Also go through the very detailed documentation:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/67efb9bb-0601-0010-f7a2-b582e94bcf8a
    Regards,
    Mahesh

  • [svn:osmf:] 13042: Fix for FM-287, reinstating the main sample ( that uses serial and parallel composition), and making another pass at  getting all the changed trait methods mapped correctly back- and forth between JS and Flash .

    Revision: 13042
    Revision: 13042
    Author:   [email protected]
    Date:     2009-12-17 03:45:27 -0800 (Thu, 17 Dec 2009)
    Log Message:
    Fix for FM-287, reinstating the main sample (that uses serial and parallel composition), and making another pass at  getting all the changed trait methods mapped correctly back- and forth between JS and Flash.
    Ticket Links:
        http://bugs.adobe.com/jira/browse/FM-287
    Modified Paths:
        osmf/trunk/apps/samples/framework/HTMLGatewaySample/HTMLGatewaySample.as
        osmf/trunk/apps/samples/framework/HTMLGatewaySample/html-template/index.template.html
        osmf/trunk/framework/MediaFramework/org/osmf/external/HTMLElement.as
        osmf/trunk/framework/MediaFramework/org/osmf/gateways/HTMLGateway.as

    Perre wrote:I'm used to being able to pick one or a couple of songs and then adding it a specified playlist. Is this impossible in sonata?
    It's clearly not impossible, just different than you expect. Create your playlist as you want it to appear in the Current tab (meaning don't dump every single song from your library in there, just the ones you want) and then save the playlist.
    Perre wrote:And if I try to play the m3u file created (the one with every song listed) through freevo I get a message that the directory is empty. What am I doing wrong??
    Look at save_absolute_paths_in_playlists in your mpd.conf.

Maybe you are looking for