Want More Freedom? It Takes Discipline.

Do you write tests? Maybe you even practice Test Driven Development (TDD)? Are you spending the time to do proper design? Are your systems rigorously monitored?  These are all important disciplines in the field of software engineering. It can feel onerous to follow these and other practices, but doing so will actually make things easier in the long run.

Although discipline demands control and asceticism, it actually results in freedom. When you have the discipline to get up early, you are rewarded with more free time. — Extreme Ownership

In other words: Discipline equals freedom.

You may think that some of these practices boxes you in or prescribe too much. What they really do is open up new freedoms in your daily routine.

Discipline of Automated Tests

It takes discipline to write tests. If you can maintain the practice of writing tests, you gain a lot of freedom. In particular, you have the luxury to:

  • Deploy any time. A large collection of automated tests gives you the confidence that your code is working as expected. Feeling secure about the quality of your code means you are able to put it in front of users more often.
  • Refactor often. When you have tests, you have the ability to change code around whenever you like. The tests provide the safety net required to do so without breaking the desired functionality.

Habits such as TDD are practices designed to help build the discipline of writing tests. I certainly have phases where I write more tests than others. But I’m always glad that I have them when it comes time to make changes.

Discipline of Design

With the constant pressure to ship products, spending time thinking about the design of your software often goes out the window. Instead of coding to interfaces, concrete implementations are used, objects take on more than one responsibility, and class hierarchies grow out of control.

Cultivating a discipline of good Object Oriented Design (OOD) means that you have the freedom to extend or replace components of your system with much less difficulty. For example, if you’ve maintained the habit of using Java interfaces instead of concrete classes, you are free to swap out implementations when the need arises.

Discipline of Monitoring

Once your code has been deployed to production, keeping track of how its behaving and performing is another good discipline to develop. A robust monitoring system gives you the freedom to proactively fix issues at a more leisurely pace, rather than when you’re under the pressure of angry users.

If you have confidence that your monitoring systems will notify you of a problem, you are free to work on other things, instead of always watching and worrying about whether there’s something wrong.

Discipline Equals Freedom

I’ve seen this idea work time and again. Whenever I’ve taken the time to write robust unit tests, things come together quickly and easily at the end, leaving more time for other things. Paying attention to how I’ve designed my classes almost always gives me the freedom to change things around with minimal disruption. Having monitoring in place has given me the flexibility to solve problems when they’re small, before they affect real users.

Many of the disciplines that go into building software are simple. They’re not always easy, but they’re around for a reason. If do the things you know you should do, you’ll be rewarded in the long run. After all, as John Wooden said, “If you don’t have the time to do it right, when will you have the time to do it over?”