2012-11-18

We had a little argument over at Gamedev.SE...



A few days ago, futlib asked a question concerning circular dependencies in his design. He was worried because his World class had a reference to his Player class, which introduced the aforementioned circular dependencies.

Though the original question concerned only circular dependencies, the discussion quickly evolved into something else, a thing which should have probably not happened in the comment section of an SE site.

The argument was spawned by Liosan's answer, which advocated the right thing to do: a partial redesign. Liosan said that the OP should probably introduce a Renderer class, because by his current design, he had a monolithic World class which took care of everything. However, a few people argued that the introduction of new classes adds unnecessary overhead and complexity to the code, which is quite a strange thing to say.

The response to that was, of course, that dividing up code into logical structures (classes) is always a good thing to do, and actually reduces complexity and increases readability; which is of course true when contrasted with having a one huge class with all of the responsibilities crammed into it, not to mention that this code will most likely not be reusable at all.

I responded too, suggesting that the OP should check out SOLID, and offered a bit more detailed alternative to his design: gamedev.stackexchange.com/a/43701/9736 (my answer).

No comments:

Post a Comment