DEV Community

Emmanuel Genard
Emmanuel Genard

Posted on • Originally published at emmanuelgenard.com on

Chapter 5: Franc-ly Speaking

Chapter 5: Franc-ly Speaking

Summary

Beck wants to implement multi-currency multiplication but can't because we only have one currency implemented, Dollar. So in this chapter he does a quick and dirty implementation of Franc. He copies the code in Dollar and renames the class Franc. Beck acknowledges that most programmers would consider this bad code but makes the case the the first goal is to get a green test. Once you have a green test, you can then improve the design with a refactoring.

Commentary

Good design at good times. Make it run, make it right.

This quote by Beck reminds me something I've heard about writing: "The only kind of writing is rewriting". It's supposedly from Ernest Hemingway. Writing is about getting something, anything, down and then working it until it's good. I think Beck is advocating the same thing for writing programs. You could say that he thinks clean code is cleaned code.

However, I almost never see this attitude. In my experience there is an expectation of a good design immediately. I feel this pressure almost every time. Every time I try to make it run then make it right, I feel like I'm doing something wrong. There seems to be an unstated norm that a good programmer is able to do a good design right away. This maybe some imposter syndrome on my part or some other projection of my fears and insecurities. Nonetheless it feels risky not not make it right, right away.

I think another reason is that I don't always know when I have a good or bad design. When is the code clean? When is it OK to leave it a little dirty? How do I know when to insist on squeaky clean and when not to? I tend to just do what feels right. I settle for "good enough" but I have many different versions of "good enough".

Good design at good times. Make it run, make it right.

What is a good design? When is it a good time? What makes it right?

Top comments (0)