Most programmers know that “magic numbers” tend to degrade code quality, but are they aware that hard-coding types (i.e. “magic typing”) often does too?

It is almost ubiquitous knowledge among educated and/or experienced programmers that “magic numbers” (i.e. hard-coding specific numeric values in multiple different locations in code) is generally highly damaging to code quality, readability, and maintainability.

It is a lot harder to change code that uses a lot of magic numbers, because every time you need to change one of those numbers you not only have to remember (or find) all the places where that number is, you have to also make sure that each instance of that number that you do find is actually related to the other ones that you are changing and not merely coincidentally the same. This can quickly become nightmarishly tedious, error prone, time consuming, and inflexible. Thus, it is common to instead use named constants so that it is easy to change all the related number instances at once in a much more foolproof way.

Continue reading Most programmers know that “magic numbers” tend to degrade code quality, but are they aware that hard-coding types (i.e. “magic typing”) often does too?

Igor’s C++ Grimoire: A hidden gem of C++ reference material that not enough people know about

There are several C++ reference and documentation pages for the C++ programming language and the standard library (std::) and STL that one inevitably ends up coming across during the course of studying C++ and trying to use/learn the built-in features and common extensions of C++ when programming.

Both C and C++ tend to not have the most memorable names for some functions and types and variables etc, and can also have some tricky special cases in terms of code behavior, so the use of reference pages for C++ coding is essentially unavoidable, even more so than usual for programming languages.

Continue reading Igor’s C++ Grimoire: A hidden gem of C++ reference material that not enough people know about

An expressive system for specifying constraints in code makes reasoning about software much easier.

Hello. Since this website is only a day or two old at this point, there is probably nobody (or almost nobody) reading it so far. However, be that as it may, I want to at least put some form of real content up now, even if it is of little significance, so that I can start to get a bit of momentum going and so that the site will no longer be totally useless. As such, on a whim, I have decided to make this post here (the 2nd post ever) about some of my personal thoughts on the importance of being able to express constraints in an effective way when doing computer programming.

Despite how obvious one might think this point is, I think the point is still worth saying here. I find that it is actually surprisingly common for many popular programming languages and related tools to have unnecessarily weak or arbitrarily limited constraint specification systems. There is also likewise a surprising abundance of programmers who don’t seem to really grasp the usefulness of an expressive constraint system either.

Continue reading An expressive system for specifying constraints in code makes reasoning about software much easier.