Give Your Old Code Some New Love

If you’re not careful, entropy creeps its way into your code base. You take a shortcut or code something in a way that you know is sloppy and you say to yourself “I’ll come back to that later”, but later you’re faced with new feature requests or some other Imminent Disaster(tm) and you don’t go back and clean up the mess you made earlier. This is only natural in a code base and when the messes are few and far between, it is tolerable.

However, at some point the messes accumulate and you need to do something about it because the mess is preventing you from making forward progress in a reasonable manner. Entire books have been written about this situation such as “Working Effectively With Legacy Code” by Michael Feathers (see my review), “Refactoring: Improving the Design of Existing Code” by Martin Fowler and “Refactoring to Patterns” by Joshua Kerievsky. One could even consider “Domain-Driven Design: Tackling Complexity in the Heart of Software” by Eric Evans to be a book full of advice about how to avoid the accumulation of entropy in your code base. Still, sometimes you find yourself with too much entropy in your code base and it’s time to do something about it.

In this post, we’ll take a look at an open source project with a code base that is over 30 years old and has accumulated some “cruft” along the way. We’ll discuss various strategies for coping with the cruft and how to get rid of it in as safe a manner as possible. After all, we don’t want to introduce bugs while we clean up cruft.

Read the rest of this entry »

Telemarketing spam is now a Turing test

Telemarketing spam has now become a Turing test and I predict it will only get moreso in the future.

(Phone rings.)
Me: Yes?
Robot: Hello, my name is Betty, I’d like to talk to you about blah blah blah.
Me: Are you a human being?
Robot: (Pause for voice recognition.) Yes! I’m just talking to you through a computer!
Me: What town were you born in?
Robot: (Pause for voice recognition.) I’m sorry, can you repeat that?
Me: You’re a robot. (Hang up.)

C++ Rename Shootout: Visual Studio 2017 vs. ReSharper for C++

In programming we have to come up with names for lots of things on a day-to-day basis. Naming things is hard. Lots of times we come up with names that we’re not particularly happy with, but it may be the best name we could think of at the time. Later we get a better idea for the name but now we have to update all the locations in the code that used the old name and change them to use the new name. Sometimes, responsibilities change and the names we originally chose no longer match the new responsibilities.

Getting help from your development environment for renaming identifiers can be a huge productivity boost. It lets you quickly and easily improve the names of things in your code. In this post, I’ll review two automatic renaming tools for C++ in Visual Studio: Visual Studio 2017 Community Edition 15.5.7 and ReSharper for C++ 2017.3.2.

Read the rest of this entry »

Two-Character Unix Commands

Here’s a fun survey question: name as many two-character Unix commands as you can and say what they do.

Let’s be precise about what we mean by a “command”:

  • Shell aliases like la are not commands.
  • Shell built-in commands count as commands; over time the shell incorporated directly things that were previously separate executables in Unix.
  • Commands not available in a wide variety of Unix distributions by default don’t count. In other words, if you have to install some optional package to get the command then it isn’t a “Unix” command.
  • Optional: Only allow commands included in a “classic” Unix from Bell Labs.

Ready? Let’s go.

Read the rest of this entry »