Green - Day 4

2013-03-28

 

I implemented my musing from yesterday. The only change is, that I kept the names InputSystem and GraphicSystem, instead of OisSystem and OgreSystem respectively. The rationale behind this is that it makes more sense to use a name that describes what they do and not what they are.

Interestingly, it suddenly dawned on my how the Law of Demeter works in practice.

For example let's take the two bits of code, that do the same thing:

Example 1:

size_t window_id = graphic->get_window_id();

Example 2:

size_t window_id;
Ogre::RenderWindow* window = graphic->get_window();
window->get_attribute("WINDOW", &window_id);

The first example follows the law of Demeter. This has as a result that the client code is more compact and the interface of the GraphicSystem wider. But that is only a collateral. The real use is that in the second example, OGRE is directly involved. This means, should the GraphicSystem ever use something other than OGRE, all clients must be altered.

But since I decided to keep it as concrete as sensibly possible I went for the second. The nasty part of OGRE is you not only get a binding on code level, but also on the art level. The thing is that you need to transform all your meshes to OGRE's mesh format and all materials to OGRE's material code. Going away from OGRE would also mean that either the assets all need to be transformed or code needs to be written to read OGRE's format. But for now I am not planing on doing that.