Filesystem Library in C++17

One of my favorite things about C++ is that it works exceptionally well cross platform. This is entirely to the work of library authors who put a lot of effort into putting a common interface on common tasks, each with a different implementation. The proposed filesystem library in C++ 17, based on the excellent boost filesystem library, in one of my favorite bits. Unfortunately it’s not entirely obvious how to use it without some deep digging. »

Makefiles for Test Driven Development

I’m a big believer in Test Driven Development. That’s the model where you write a failing test, then you write just enough code to make the test pass, but no more. It sounds counter-intuitive,but experience has shown that I get a finished, deliverable product a lot faster, and I’m less likely to find bugs. Even more importantly, my customers are less likely to find bugs. Setting up a Makefile to support test driven development adds some additional challenges to what I’ve shown in my earlier articles. »

Clay's Blueberry Pie Recipe

I’ve cobbled this recipe together from various sources, starting with my grandmother’s pie crust recipe, and adding in things I learned from my mother and reading cooking magazines. Tools This recipe requires a kitchen scale capable of measuring in grams. It’s important to keep the ratios of liquids to solids correct, or you’ll have a bad time. Learn from my pain. Stage 1 Ingredient grams Cumulative grams Flour 180 Salt 1 181 Lard 102 283 Measure the ingredients into a bowl on the scale, looking for the cumulative balance total on your scale for each step. »

Mocking System APIs

One problem a lot of people run into is the need to test code that uses APIs they don’t control. This came up tonight during a discussion on mocking at the Pillar Technology Plugged In event in Ann Arbor. The system in question was a remote service, but I encountered it recently with UNIX system calls. Fortunately there’s a simple solution. If you wrap the APIs in a class, you can mock that class. »

Better Tests Through Mocking

If you have even a moderately complex application, writing tests can be a real pain. You either wind up writing complex, fragile tests, or you skip it altogether. There is a third path: fake out all of the parts that you aren’t testing in this test. You can examine the fake parts to see what has been done with them, and you can make them respond however you want to your program. »