Skip to main content
added 1 character in body
Source Link
Euphoric
  • 38.2k
  • 6
  • 82
  • 120

I'm for 2, but with slight modification. I wouldn't use enum. You can just as fine use typeofGetType(). If you were to add enum to the mix, it would duplicate the type information contained within the object.

On top of that, I would create an Visitor for the Choice class. This will remove the need for reflection and give UI type-safe way to create textual representation for each choice. It will also ensure that when you add new choice type, the compiler will force you to implement all related code, like creating a textual representation for it. And I don't see how having many classes is bad. It is actually good thing, as long as those classes are cohesive.

And I don't think those objects will contain only data. They can very well be objects doing the actual action. Just put Execute() method on them, and they can be the ones drawing the cards from decks or allocating points to buckets.

I'm for 2, but with slight modification. I wouldn't use enum. You can just as fine use typeof(). If you were to add enum to the mix, it would duplicate the type information contained within the object.

On top of that, I would create an Visitor for the Choice class. This will remove the need for reflection and give UI type-safe way to create textual representation for each choice. It will also ensure that when you add new choice type, the compiler will force you to implement all related code, like creating a textual representation for it. And I don't see how having many classes is bad. It is actually good thing, as long as those classes are cohesive.

And I don't think those objects will contain only data. They can very well be objects doing the actual action. Just put Execute() method on them, and they can be the ones drawing the cards from decks or allocating points to buckets.

I'm for 2, but with slight modification. I wouldn't use enum. You can just as fine use GetType(). If you were to add enum to the mix, it would duplicate the type information contained within the object.

On top of that, I would create an Visitor for the Choice class. This will remove the need for reflection and give UI type-safe way to create textual representation for each choice. It will also ensure that when you add new choice type, the compiler will force you to implement all related code, like creating a textual representation for it. And I don't see how having many classes is bad. It is actually good thing, as long as those classes are cohesive.

And I don't think those objects will contain only data. They can very well be objects doing the actual action. Just put Execute() method on them, and they can be the ones drawing the cards from decks or allocating points to buckets.

Source Link
Euphoric
  • 38.2k
  • 6
  • 82
  • 120

I'm for 2, but with slight modification. I wouldn't use enum. You can just as fine use typeof(). If you were to add enum to the mix, it would duplicate the type information contained within the object.

On top of that, I would create an Visitor for the Choice class. This will remove the need for reflection and give UI type-safe way to create textual representation for each choice. It will also ensure that when you add new choice type, the compiler will force you to implement all related code, like creating a textual representation for it. And I don't see how having many classes is bad. It is actually good thing, as long as those classes are cohesive.

And I don't think those objects will contain only data. They can very well be objects doing the actual action. Just put Execute() method on them, and they can be the ones drawing the cards from decks or allocating points to buckets.