Saturday, 11 March 2017

Planning the source code release of Teemu 1.3

I think the source code of Teemu 1.3 is going to be more important than the game itself, but it's just an opinion I guess. The game is also released with the source code, so there is no need to compile it in Windows environment at least.

Since last time I have learned some new tricks which are better use of namespace and functions. Namespaces have two main purposes in my thinking. The first one is replace notation additions to enums etc. using a module type name for stuff. Like for example door::Wooden, rather than use notation doorWooden in enums. Namespace is safer, and you can remove the door:: when using in some places. Also, what I find great is searching by using door:: namespace, you can quickly find all places where it's used outside of the namespace itself. The second use is with functions as a kind of module.

Functions are another funny thing, because when you learn OOP you may want to make "everything" a class which in some cases is clumsy, because you have to create an instance of a class to get some trivial data etc. Functions are even better with namespaces, because you can then create sort of static "namespace class" or module with C-style functions as member functions of it. The nice thing in C functions is that there is no need to create an instance so there is no problems with memory management in that case (unless of course you use memory management in those functions which I never do). Writing pure functions is really nice I think and they are very useful when generalized, because you can use them in any place of the source code without so called side effects.

Those are the two main improvements, but there are others like smaller classes with more focused tasks and so on. The reason why I think this is important is that I've been talking a lot about C++ programming and why you should do certain things. But when I only talk about it no one is listening. So I think it's far better to lead with an example. I want to show how you can write large-ish projects with zero bugs when you concentrate on creating a set of rigid rules in programming.

The release of Teemu 1.3 is not very far away I believe. Depending on how well I'm able to allocate the time for this project.

No comments: