In the previous blog post I wrote how you can have a simple ‘to string‘ method for a C++ object. My proposed solutions however, like in all languages, require you to have access to the code of that class and be able to alter it. There is however a way that allows you to ‘extend’ a class with some methods without needing actual access to the source code. In this blog post I will show you how you can implement output stream operator <<, and then discuss this approach more generally.
It won’t be long before you run into the situation where you want to print an object. And when you do so, you of course want to have a meaningful representation of your object and not just the memory address. In Java and Python you have ‘special’ methods that are meant to do this translation for you, being toString and __str__ and __repr__ respectively. But what about C++?
I always believed (and still do) that logging and debugging served a very different function. Where logging is provided to be able to check the status of a system, as some sort of feedback what is going on. Whereas debugging is aimed at fine-grained inspection of the system most likely because it is behaving wrongly and you are trying to find out why.
Nevertheless the approach of adding logging statements as a way of debugging is common, which is enough reason to discuss the different approaches and compare them with each other.
In the previous blog post I examined the ‘meaning’ (or context if you like) of an event. I come to the conclusion that simply keeping an event as a trigger to indicate something happened is, in my opinion, the best approach. But how does this relate to the information shown to the user? That is what I will investigate in this blog post.
Events are common in many systems, but there exists different ways to implement them. The difference between two main approaches relies on the semantics of an event, what is considered to be an event. Checking out a couple of online dictionaries we can find the following descriptions:
- [Cambridge Dictionary]: anything that happens, especially something import or unusual.
- [Dictionary.com]: something that happens or is regarded as happening; an occurrence, especially one of some importance.
It is the ‘is happening’ part in the last definition that causes the different views. Should an event hold a certain state? In this blog post, I will investigate and discus the pros and cons of having a state for your events.
Call me a perfectionist, but I often have issues when trying to come up with a good design. Every design I come up with, I find a couple of things I don’t like and that I would like to see improved. As a result I spend a lot of time on trying better designs, even if the impact of it isn’t that big. It can take up so much time of me going back and forth on a design that I just have to tell myself to settle for my current best design. In this blog post I will go deeper about my thinking and feelings when faced with this issue.
One of the biggest missing features of the current Object Saving Framework is that there is no native support for lists. There is a way to bypass the issue, but it’s a nasty one. In this blog post I first go into depth about how to bypass the issue, this will make it clear that native support is essential, and finally I will discuss some issues with supporting it.