The C++ visibility model is broken by design. By visibility model I mean using the keywords private, public and protected to manage how objects relate to each other.
I will explain exactly how such model is broken and propose a workaround to it. I admit I am not the first one to realize that, as I have been writting C++ for just a decade, whereas there are more skilled programmers than me or with way more experience.
Read more ...
TL-DR: make the getInstance() method of a Singleton return an abstract type and allow it to be overriden at link-time.
Disclaimer: the technique here explained is maybe as old as C++. I don’t claim to be the author of the idea. I just wish I had learned it 10 years ago.
So you hate, or at least dislike, the Singleton pattern, right?
I am not its fan and can’t recall the last time I created one, but we must accept the fact that they exist in the wild, specially in legacy codebases.
Read more ...
Well, after many years (really) I decided, again, to make a blog. As usual, it will be mostly about software development and other things that happen between my ears.
Stay tuned!
Read more ...