jeudi 2 juillet 2020

Association or Aggregation relationship for Facade design pattern?

I'm studying the GoF design patterns, in particular the Facade pattern. I understand its use and implementation, but I have a doubt about its UML model. The solution proposed by my professor, summarized, is the following:

public class Facade{
    private ClassA c1;
    private ClassB c2;
    private ClassC c3;

    public Facade(){
        this.c1 = new ClassA;
        this.c2 = new ClassB;
        this.c3 = new ClassC;
    }

    public void FacadeMethod(){
        ...
        c1.operationA();
        c2.operationB();
        c3.operationC();
        ...
    }

}

The UML model proposed is like this: Facade UML Model

The Facade Class has an association relationship with the classes ClassA, ClassB, ClassC. However should these be aggregation relationships? The Facade Class has reference c1 to ClassA, c2 to ClassB and c3 to ClassC, so i think it's a "HAS-A" relationship. Any Idea?

Aucun commentaire:

Enregistrer un commentaire