In most programming languages, you can create your own types. This is a major productivity boost, I would not recommend using a language that does not allow this. Here, I’m going to try to categorize the types that you might create, and assign some properties to the categories. Then, I’ll make some recommendations for language designers to consider when creating their languages.
If you read the title, you probably already know what categories I’m going to use: Data and Objects. Before we get into the nitty gritty, lets think about some things people might typically associate with Data and Objects.
Much has been said about how much testing is appropriate for software. For safety-critical programs like aviation software, you better have 100% coverage. For your side projects and scripts you are going to run once, you probably don’t need any testing. For everything in-between, you probably need, well, something in-between.
But how much testing you should do is not what I’m here to talk about today. Instead, I’m going to talk about how to get the most bang for your buck in testing — getting the most coverage from the fewest hours of effort.
This is actually going to be…
Programmers write a lot of wrapper functions. Sometimes the wrappers do a lot, and sometimes only a little. Sometimes they do too much. The goal of this post is to come up with a taxonomy of wrapper functions, with examples of each. I’d also like to suggest that if you are writing a function and it fits into multiple of these categories, if might be doing too much, and you should consider breaking it up into multiple wrappers, which can be called in sequence.
I’ve also noticed that term “thin wrapper” gets a lot of use, and different people use…
I’ve been reading a bunch of articles about
std::optional<T&> recently, and it’s a very contentious topic. In C++ 17, attempting to create a
std::optional<T&> will result in a compile error. There are some people who are disappointed with this state of affairs, and with good reason: If you are writing some generic code, and inside your implementation, you want to use a
std::optional<T>, then you must jump through a lot of hoops if you want to support
T being a reference type. Yikes.
This hasn’t been added to C++ yet, because people can’t agree on the semantics of
It’s not too uncommon for people to want to put a function in a separate “mode” in unit tests only. Maybe in the non-test mode you want to write output directly to
stdout , but in unit tests you want to write to an internal buffer that you can check the contents of in the test. Maybe in the test you want to fetch data from a file, but that would be unsafe to do in non-test code so you want to prevent that from being accidentally done in non-test code.
In this post, I’m going to show you how…