Programming games are fun. It always has been. But games are also software, so they also need the proper organization of code. Proper organization of the code helps reusing it many more times when needed or reusing parts of it. From a software perspective, games need to follow some programming paradigm, after structured programming came OOP (Object Oriented Programming) and now CES (Component Entity Systems).
There are many books, articles and forum post out there discussing/proving the need to transfer from structured languages like – C to OOP languages like – C++. Now it’s changing towards component entity systems. No one is advising to change any language but rather think differently.
So what is the difference between OOP and CES? In one sentence, OOP is about inheritance and CES is about composition of objects. But do we really need CES? Or a better question might be isn’t CES also a subset of OOP?
Whatever posts or articles I have seen on CES tells the problems of inheritance and shows us the path towards composition. But I really don’t see why composition isn’t being considered as OOP. Many books I have read on Java, C++ and general OOP advises to use composition instead of inheritance when necessary. Some books even advised to think about composition first and if that doesn’t solve the problem then use inheritance.
In CES, components tend to have only data (in most cases) but every OOP language provides/accepts defining a class with only data, that means it is accepted in OOP. Entities contain needed components (Composition, also allowed in OOP and is OOP) and systems act on them (functions/methods, polymorphism etc. pure OOP).
So every CES is OOP, but not every OOP is CES (remember, Inheritance).
So what am I trying to say? Remove the concept of CES? NO. Absolutely not. CES has some nice features like – dynamic plugging, better reuse etc. My point is that, whenever it’s better to use inheritance, we will use it and whenever inheritance is not the better solution then we will use composition and will still call that OOP, not CES.