#Factory with 2 methods or 2 different Factories?

8 messages · Page 1 of 1 (latest)

vivid kiln
#

Suppose I have a Shape interface, implemented by Square, Triangle, Circle, etc.
I'd like to construct those shapes in 2 different ways:

  • first, by passing an enum that tells it what shape to give me back
  • secondly, by giving me a random shape back
    Both ways of creating a Shape would share some logic, since I'm interesting in getting shapes that don't overlap on an XOY coordinate system.

Would it be better to get make a single Factory with 2 methods or 2 Factories with a method each?

tiny mauveBOT
#

Hey, @vivid kiln!
Please remember to /close this post once your question has been answered!

acoustic otter
#

Here the better way is the one that suits the program's mindset the most. It's all entirely subjective

vivid kiln
#

what would be the advantages/disadvantages of choosing one over the other?

acoustic otter
#

Clarity and conformity to expectations/lack of clarity and surprise compared to expectations

spice elk
#

lol I like that username

#

however, I would add a -- at the end