Sunday 29 September 2013

Flaws Of Object Centric Programming



When thinking about how to create a game’s framework from a high level, we will see that there things that have similar features. From this we group them other, and assign them all to inherit from 1 parent. This can be seen in many games and can be applied the simple game of pack man as shown to the left. This way of thinking for programming is called object centric programming, due to the fact there is a lot of polymorphism, resulting in the huge “is a” chain.



However there are many flaws to this way of programming, which could be devastating for large scale games. When drawing the UML diagram, we can predict a big list to form due to the huge chain of inheritance. From this we can predict that this method will be inefficient, whenever we create a single object we must also create a version of the parent in the memory. If that parent also had a parent, we would have to save some memory for that. Double Polymorphism, is another problem which can cause HUGE errors if done, one case is shown in the chart to the right. Finally if every class in the chain was modified and this resulted in errors, the question comes up, where would the source of these errors be?

In the end we learn that this is one of the framework patterns which has issues with some games. We must be careful and plan how to program games ahead of time so that we won’t run into issues like that.
In short you should have double polymorphism also known as the the criss crossing diamond.

No comments:

Post a Comment