B
B
beesent2017-12-05 18:15:01
Software design
beesent, 2017-12-05 18:15:01

How to replace the abstract factory in this case?

I ran into a problem, I need to implement 50 types of doors and each one should have its own factory? Really, I will need to create as many as 100 classes? How can this problem be solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Night, 2017-12-06
@maxtm

No matter how stupid it sounds, but replace the abstract factory with any other factory.

Class MyDoorFactory {
 public function factory($door) {
  $class = 'MyNamespace\\' . $door;
  return new $class;
 }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question