A
A
atis //2016-10-26 10:57:40
OOP
atis //, 2016-10-26 10:57:40

What is the difference between association, aggregation and composition at the code level?

Hello.
Bayan is rare, but there still seems to be no clear answer to it.

class Aggregation
{
    protected $obj;

    public function __construct(Model $Model)
    {
        // Не является ли это ассоциацией?
        $this->obj = $Model;
    }
}


class Composition
{
    protected $obj;

    public function __construct()
    {
        // Не является ли это ассоциацией?
        $this->obj = new Model();
    }
}

So. What is the difference?
UPD: in my understanding, an association is an abstract version of aggregation and composition.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
atis //, 2016-10-26
@atis2345

softwareengineering.stackexchange.com/questions/23...
stackoverflow.com/questions/13044984/difference-be...
Wiki: "Association shows that objects of one entity (class) are related to objects of another entity in such a way that one can navigate from objects of one class to another is a general case of composition and aggregation."
Class diagram
There are many unnecessary articles for aggregation and composition, although everything is very clear there, in the case of association there is no clear definition.
UPD: java-course.ru/begin/relations

R
romy4, 2016-10-26
@romy4

atis // : well, here is more info and smart. really about the association can not be described in two sentences

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question