lundi 21 décembre 2020

Should I use abstract factory design pattern?

At the moment my code looks like this. I have used abstract factory design pattern.

Diagram

My job is to create shapes. The problem is that these shapes are really complex to create. ShapeFactory has to know multiple different values to be able to create a shape. Because of that I have created ObjA which contains the necessary information to create the shape. This creates the problem that the modules are linked together by ObjA.

In examples like here the make methods parameter is a String but to me in this case it seems to hard to replace the ObjA with a String.

Should I use AbstractFactory design pattern in this kind of a problem? Is there a solution where I can keep ObjA and also keep the modules seperated?

(I am using Java and android studio in my project)

Aucun commentaire:

Enregistrer un commentaire