0

I'm developing a game, I will generate objects. I have create an interface called IObject which has the following properties:

String tag // Tag for the object
Vector3 position // Where the element is positioned
Mesh mesh // This is how the object looks like
Material material // The material from which the object is build
void draw() // Method which draw the object

Now I wonder which will be better design practice to create another interface which takes all the things associated with drawing (position, mesh, material and the draw method) or to leave it this way?

closed as primarily opinion-based by BЈовић, durron597, user22815, user40980, Ixrec Aug 27 '15 at 19:55

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

3

Definitely take the stuff that relates to drawing out. Something like Drawable or Sprite or anything which clarifies the specific intended purpose of the object would be better

Interfaces are useful because they establish a specific contract regarding what you expect an object to provide; they should only include as much functionality as they need to for a specific range of use cases. Remember, objects can implement multiple interfaces; you don't have to have one giant interface which defines everything you could ever need in all cases, because that will get bloated and harder to mock for testing purposes. Single responsibility is your friend!

Not the answer you're looking for? Browse other questions tagged or ask your own question.