Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. Composition??

Composition??

Scheduled Pinned Locked Moved The Lounge
tutorialquestion
39 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    class car { }; class red { }; class RedCar : public red, public car { };

    G Offline
    G Offline
    Germyan
    wrote on last edited by
    #8

    That is rather a good one than the one at wiki.. but the practicality of the class red is questionable.. I think there are better ones.. G.

    L 1 Reply Last reply
    0
    • G Germyan

      Can I have your best example, to illustrate this relation with respect to OOP concepts? No physical world example please.. I have seen people go very wrong, when they try to explain this.. G.

      S Offline
      S Offline
      Shog9 0
      wrote on last edited by
      #9

      I need a collection type that will store objects. It will let me iterate through the objects it contains, access them by ordinal, or retrieve a subset of them matching a given attribute. I might compose this type from an array (iteration, ordinal lookup) and a tree (attribute lookup - match a branch).

      G 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        The fact that you can decompose the objects does not invalidate the scenario.

        Need a C# Consultant? I'm available.
        Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

        G Offline
        G Offline
        Germyan
        wrote on last edited by
        #10

        It does.. That is why you have three different relations named association, aggregation and composition.. You can cover all by aggregation and composition can cover with aggregation but when you defined a composition, it is special and cannot be covered by any of the other two. Your or the one you pointed comes under aggregation not composition.. so you cannot argue any longer with your example.. :(

        E 1 Reply Last reply
        0
        • S Shog9 0

          I need a collection type that will store objects. It will let me iterate through the objects it contains, access them by ordinal, or retrieve a subset of them matching a given attribute. I might compose this type from an array (iteration, ordinal lookup) and a tree (attribute lookup - match a branch).

          G Offline
          G Offline
          Germyan
          wrote on last edited by
          #11

          yes, that is also a good one.. when objects are not existing you will not have the collection defined. But when you have one to many relation in between the collection and object it again comes under aggregation.. so it is also not composition.. Additional object can exist without a collection.. I think you are also wrong ... :( G.

          S 1 Reply Last reply
          0
          • G Germyan

            It does.. That is why you have three different relations named association, aggregation and composition.. You can cover all by aggregation and composition can cover with aggregation but when you defined a composition, it is special and cannot be covered by any of the other two. Your or the one you pointed comes under aggregation not composition.. so you cannot argue any longer with your example.. :(

            E Offline
            E Offline
            Ennis Ray Lynch Jr
            wrote on last edited by
            #12

            From the Agile Definition: 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. I don't see what the big deal is.

            Need a C# Consultant? I'm available.
            Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

            G 1 Reply Last reply
            0
            • G Germyan

              So the Carburetor and Car is a software world example??.. I don't think so.. But, again can the Carburetor exist without the car? I think Yes, so then why you say it is Composition it is Aggregation, doesn't it????? I think that WIKI example is a poor one and your answer is also a poor one.. :) G.

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #13

              Germyan wrote:

              So the Carburetor and Car is a software world example??.. I don't think so..

              Is the Carburetor and Car the only example on that page??.. I don't think so.. But, again I don't expect you are someone that reads technical information efficiently.

              Germyan wrote:

              I think that WIKI example is a poor one and your answer is also a poor one..

              I think your effort is a poor one, your reply is a poor one, and it's a fair assumption you are a poor one.

              led mike

              G 1 Reply Last reply
              0
              • G Germyan

                yes, that is also a good one.. when objects are not existing you will not have the collection defined. But when you have one to many relation in between the collection and object it again comes under aggregation.. so it is also not composition.. Additional object can exist without a collection.. I think you are also wrong ... :( G.

                S Offline
                S Offline
                Shog9 0
                wrote on last edited by
                #14

                Wait - just what do you think aggregation is? And why do you think composition isn't aggregation? :suss:

                G 1 Reply Last reply
                0
                • G Germyan

                  That is rather a good one than the one at wiki.. but the practicality of the class red is questionable.. I think there are better ones.. G.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #15

                  Germyan wrote:

                  but the practicality of the class red is questionable.. I think there are better ones..

                  you just cant please some people

                  G 1 Reply Last reply
                  0
                  • E Ennis Ray Lynch Jr

                    From the Agile Definition: 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. I don't see what the big deal is.

                    Need a C# Consultant? I'm available.
                    Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                    G Offline
                    G Offline
                    Germyan
                    wrote on last edited by
                    #16

                    You can bring up definition, but as a software developer and a one who visit code-project regularly, show me a real place where you have ever used this.. I can bring you thousand of cut and paste definitions as well as physical world's examples.. but the question is something else..

                    Ennis Ray Lynch, Jr. wrote:

                    I don't see what the big deal is.

                    Then you stay out of this.. This is a challenge if you are ready to accept it accept, if not you can go away.. I am sorry if it is rude :rolleyes:

                    E 1 Reply Last reply
                    0
                    • G Germyan

                      You can bring up definition, but as a software developer and a one who visit code-project regularly, show me a real place where you have ever used this.. I can bring you thousand of cut and paste definitions as well as physical world's examples.. but the question is something else..

                      Ennis Ray Lynch, Jr. wrote:

                      I don't see what the big deal is.

                      Then you stay out of this.. This is a challenge if you are ready to accept it accept, if not you can go away.. I am sorry if it is rude :rolleyes:

                      E Offline
                      E Offline
                      Ennis Ray Lynch Jr
                      wrote on last edited by
                      #17

                      Poor communication is a challenge best left to those with weak minds.

                      Need a C# Consultant? I'm available.
                      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                      G 1 Reply Last reply
                      0
                      • L led mike

                        Germyan wrote:

                        So the Carburetor and Car is a software world example??.. I don't think so..

                        Is the Carburetor and Car the only example on that page??.. I don't think so.. But, again I don't expect you are someone that reads technical information efficiently.

                        Germyan wrote:

                        I think that WIKI example is a poor one and your answer is also a poor one..

                        I think your effort is a poor one, your reply is a poor one, and it's a fair assumption you are a poor one.

                        led mike

                        G Offline
                        G Offline
                        Germyan
                        wrote on last edited by
                        #18

                        Come up with valid facts.. I like to hear you. :~ Anyway, I like, if you can stick with the OP, rather than shooting off target to cover your not knowingness. :( You don't have an answer do you?? G.

                        L 1 Reply Last reply
                        0
                        • E Ennis Ray Lynch Jr

                          Poor communication is a challenge best left to those with weak minds.

                          Need a C# Consultant? I'm available.
                          Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                          G Offline
                          G Offline
                          Germyan
                          wrote on last edited by
                          #19

                          Ennis Ray Lynch, Jr. wrote:

                          Poor communication is a challenge best left to those with weak minds.

                          Don't shoot off target.. If the communication is the problem I will try my best to correct it. However the OP question is a simple one.. show me a example where you really used composition in any of your system. Isn't that not clear? G.

                          1 Reply Last reply
                          0
                          • S Shog9 0

                            Wait - just what do you think aggregation is? And why do you think composition isn't aggregation? :suss:

                            G Offline
                            G Offline
                            Germyan
                            wrote on last edited by
                            #20

                            I am referring to the definitions, composition is a special type of a aggregation, so I am not telling that composition is not aggregation. But what I said was that the example you gave does not have that specialty to recognize as it is composition. G.

                            S 1 Reply Last reply
                            0
                            • G Germyan

                              I am referring to the definitions, composition is a special type of a aggregation, so I am not telling that composition is not aggregation. But what I said was that the example you gave does not have that specialty to recognize as it is composition. G.

                              S Offline
                              S Offline
                              Shog9 0
                              wrote on last edited by
                              #21

                              Germyan wrote:

                              But what I said was that the example you gave does not have that specialty to recognize as it is composition.

                              Ok then. Please explain to me what's missing in my example.

                              G 1 Reply Last reply
                              0
                              • G Germyan

                                Come up with valid facts.. I like to hear you. :~ Anyway, I like, if you can stick with the OP, rather than shooting off target to cover your not knowingness. :( You don't have an answer do you?? G.

                                L Offline
                                L Offline
                                led mike
                                wrote on last edited by
                                #22

                                I believe the section of that wikipedia page on Aggregation covers the topic very clearly and correctly. But of course you would have to read it to know that wouldn't you now?

                                Germyan wrote:

                                You don't have an answer do you??

                                I know I have an answer to the problem called Germyan. I won't read any more of your messages. X|

                                led mike

                                G 1 Reply Last reply
                                0
                                • L Lost User

                                  Germyan wrote:

                                  but the practicality of the class red is questionable.. I think there are better ones..

                                  you just cant please some people

                                  G Offline
                                  G Offline
                                  Germyan
                                  wrote on last edited by
                                  #23

                                  Josh Gray wrote:

                                  you just cant please some people

                                  :confused::confused: G.

                                  1 Reply Last reply
                                  0
                                  • S Shog9 0

                                    Germyan wrote:

                                    But what I said was that the example you gave does not have that specialty to recognize as it is composition.

                                    Ok then. Please explain to me what's missing in my example.

                                    G Offline
                                    G Offline
                                    Germyan
                                    wrote on last edited by
                                    #24

                                    you are missing a important one.. when a composition is destroyed, are the objects belonging to it be destroyed as well? If the answer is NO then it is AGGREGATION. G.

                                    S 1 Reply Last reply
                                    0
                                    • L led mike

                                      I believe the section of that wikipedia page on Aggregation covers the topic very clearly and correctly. But of course you would have to read it to know that wouldn't you now?

                                      Germyan wrote:

                                      You don't have an answer do you??

                                      I know I have an answer to the problem called Germyan. I won't read any more of your messages. X|

                                      led mike

                                      G Offline
                                      G Offline
                                      Germyan
                                      wrote on last edited by
                                      #25

                                      :laugh: :laugh: :laugh: I am sorry, if I did something wrong here.. but I know most people don't know the concepts they play with on day to day basis. Just thought to play on it.

                                      led mike wrote:

                                      problem called Germyan.

                                      :laugh: - creative one G.

                                      L 1 Reply Last reply
                                      0
                                      • G Germyan

                                        you are missing a important one.. when a composition is destroyed, are the objects belonging to it be destroyed as well? If the answer is NO then it is AGGREGATION. G.

                                        S Offline
                                        S Offline
                                        Shog9 0
                                        wrote on last edited by
                                        #26

                                        Germyan wrote:

                                        you are missing a important one.. when a composition is destroyed, are the objects belonging to it be destroyed as well? If the answer is NO then it is AGGREGATION.

                                        AFAIK, there's a little bit more to it than that... but i'll bite: where in the example that i gave you did i imply that any part of my composite collection type would not be destroyed along with the collection? Granted, i did not explicitly state that it wouldn't leave bits and pieces of itself orphaned and scattered all over Creation... but i didn't think it was necessary to state such an obvious requirement.

                                        G N 2 Replies Last reply
                                        0
                                        • S Shog9 0

                                          Germyan wrote:

                                          you are missing a important one.. when a composition is destroyed, are the objects belonging to it be destroyed as well? If the answer is NO then it is AGGREGATION.

                                          AFAIK, there's a little bit more to it than that... but i'll bite: where in the example that i gave you did i imply that any part of my composite collection type would not be destroyed along with the collection? Granted, i did not explicitly state that it wouldn't leave bits and pieces of itself orphaned and scattered all over Creation... but i didn't think it was necessary to state such an obvious requirement.

                                          G Offline
                                          G Offline
                                          Germyan
                                          wrote on last edited by
                                          #27

                                          I think you said that it is a objects collection.. inside the collection you will have objects, They used a famous example to explain composition.. house vs room, can the room exist without a house?? NO Can the object exist without a collection?? YES.. so your example is not composition. I mean there are many areas, where your example violate the original definition of the composition. But, I do agree that it is the closest example, I get so far. G.

                                          S 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups