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 777881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:40:46+00:00 2026-05-14T19:40:46+00:00

I have read some posts about the differences between these 3 relationships and I

  • 0

I have read some posts about the differences between these 3 relationships and I think I get the point.

I just wonder, are all these written the same when coding?

Question 1: all 3 are just a value of the object type in a instance variable?

class A {
    public $b = ''

    public function __construct($object) {
         $this->b = $object // <-- could be a association, aggregation or a composition relation?
    }
}

Question 2: does it have to be an instance variable or can it be a static one?

class A {
    public static $b = '' // <-- nothing changed?

    public function __construct($object) {
         $this->b = $object
    }
}

Question 3: is there a difference in where the object is created?

I tend to think that composition object is created inside the object:

class A {
    public $b = ''

    public function __construct() {
         $this->b = new Object // is created inside the object
    }
}

and aggregation/association is passed through a constructor or another method:

class A {
    public $b = ''

    public function __construct($object) { // passed through a method
         $this->b = $object
    }
}

Question 4: why/when is this important to know. Do I have to comment an object inside another what relation its about or do you do it in an UML diagram?

Could someone shed a light on these questions?

  • 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-14T19:40:46+00:00Added an answer on May 14, 2026 at 7:40 pm

    You are right that these are typically realized as object references, which of course are usually just member fields of some class. This is only because it’s natural in an object-oriented system, this can map to other things in different contexts, e.g. foreign keys in a relational database.

    As mentioned by @erisco the specifics of the relationship can only be taken in context of the overall model. For example, we can read a composition relationship between a Purchase Order and an Order Line like this (for example): a Purchase Order comprises one or more Order Lines.

    I usually interpret the three you give as follows:

    1. Association: A knows of B, B has meaning in its own right.
    2. Aggregation: A includes B, B is externally identifiable and may exist on its own merits.
    3. Composition: A comprises B, B is not externally identifiable or does not have meaning outside of this composition.

    That said, I have seen these used to mean pretty much anything that can be dreamed up (and there are very likely people on SO who will disagree with my assessment!) so take care when interpreting someone else’s diagrams 🙂 The above conventions have served me well but YMMV.

    Re question 2: A static reference would yield a common association across instances, but it is just one way to implement that, and might be surprising to consumers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The only way I know of is to poll the… May 17, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer I've temporarily soved the issue by re-ordering the script calls… May 17, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer The only link I see is: http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo and it seems… May 17, 2026 at 12:56 am

Trending Tags

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

Top Members

Related Questions

Looking at examples about socket programming, we can see that some people use AF_INET
I need a way to read and delete text between two different strings found
I'm pretty new to Android development, but I have some experience with Java and
I am used to developing in PHP/MySQL and have no experience developing with SQL
I understand the concept of database normalization, but always have a hard time explaining
I am new at MVC in Asp.Net and while i am reading about the
I've started to learn Ruby recently, and was wondering about which version to learn.
I want to build a .NET REST client using C#, and although i read
Background I'm trying to get obtain a unique identifier out of a computer and
I see a lot of articles and posts on how to create a custom

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.