Saturday, 18 November 2023

Obvious invention

Previously I thought that some classes just become large and complex, but I was maybe wrong. You can create complex classes and implement stuff that way, but once again I find myself refactoring the code to detach complex "stuff" from classes and moving it elsewhere, usually in functions.

The big reason to do it this way is that you can create modules (files in C++) with themes which in turn makes project management much easier. As an example I'm moving everything that has to do with creating plants to one module. That way, even if you have more complex C-style function parameter interface, it's still better than distributing that stuff into classes or even one dedicated class. I have some dedicated classes for some operations, but strangely classes don't work well in that role. Classes work when they have (store) associated data and only have one task to do.

So, how does this change the project's development? I would like to think it does make a difference, because when modules are distinct you can concentrate on some specific task without searching stuff from several files and classes, and possibly also creating duplicate code or algorithms. Functional or procedural action code is easier to understand and I'm still using game object classes in them which means they do implement virtual functions and inheritance, which itself is making complexity easier to handle.

No comments:

Post a Comment