Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 903631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:54:55+00:00 2026-05-15T15:54:55+00:00

I’m reading some books about Design Patterns and while some describe the relation between

  • 0

I’m reading some books about Design Patterns and while some describe the relation between the abstraction and the implementation as a composition, some describe it as an aggregation. Now I wonder: is this dependant on the implementation? On the language? Or context?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:54:56+00:00Added an answer on May 15, 2026 at 3:54 pm

    The terms “composition” and “aggregation” mean more or less the same thing and may be used interchangeably. Aggregation may be used more frequently when describing container classes such as lists, dynamic arrays, maps, and queues where the elements are all of the same type; however, both terms may be found to describe classes defined in terms of other classes, regardless of whether those types are homogenous (all of the same type) or heterogenous (objects of different types).

    To make this clearer:

    class Car {
        // ...
        private:
            Engine engine;
            Hood hood;
    };
    
    // The car is *composed* of an engine and a hood. Hence, composition. You are
    // also bringing together (i.e. *aggregating*) an engine and hood into a car.
    

    The relationship between abstraction and implementation typically implies inheritance, rather than composition/aggregation; typically the abstraction is an interface or virtual base class, and the implementation is a fully concrete class that implements the given interface. But, to make things confusing, composition/aggregation can be a part of the interface (because, for example, you may need to set/get the objects that are used as building blocks), and they are also an approach to implementation (because you might use delegation to provide the definition for methods in your implementation).

    To make this clearer:

    interface Car {
        public Engine getEngine();
        public Hood getHood();
        public void drive();
    }
    // In the above, the fact that a car has these building blocks
    // is a part of its interface (the abstraction).
    
    class HondaCivic2010 implements Car {
        public void drive(){ getEngine().drive(); }
        // ...
    }
    // In the above, composition/delegation is an implementation
    // strategy for providing the drive functionality.
    

    Since you have tagged your question “bridge”, I should point out that the definition of the bridge pattern is a pattern where you use composition rather than inheritance to allow for variation at multiple different levels. An example that I learned at college… using inheritance you might have something like:

    class GoodCharacter;
    class BadCharacter;
    class Mage;
    class Rogue;
    class GoodMage : public GoodCharacter, Mage;
    class BadMage : public BadCharacter, Mage;
    class GoodRogue : public GoodCharacter, Rogue;
    class BadRogue : public BadCharacter, Rogue;
    

    As you can see, this kind of thing goes pretty crazy, and you get a ridiculous number of classes. The same thing, with the bridge pattern, would look like:

     class Personality;
     class GoodPersonality : public Personality;
     class BadPersonality : public Personality;
    
     class CharacterClass;
     class Mage : public CharacterClass;
     class Rogue : public CharacterClass;
    
     class Character {
        public:
            // ...
        private:
            CharacterClass character_class;
            Personality personality;
     };
     // A character has both a character class and a personality.
     // This is a perfect example of the bridge pattern, and we've
     // reduced MxN classes into a mere M+N classes, and we've
     // arguably made the system even more flexible than before.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 446k
  • Answers 446k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Cascading Deletes is something that I always stay away from.… May 15, 2026 at 7:05 pm
  • Editorial Team
    Editorial Team added an answer I applied all the css method, but not get proper… May 15, 2026 at 7:05 pm
  • Editorial Team
    Editorial Team added an answer Yes, this pretty much is the solution for this problem.… May 15, 2026 at 7:05 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.