Clean Code
I just saw a talk by Robert Martin called “Clean Code” that was pretty eye opening. He walked through the process of coding a small app that parsed command line parameters. He demonstrated a rather common process of creating a small application with a specific function that, when requirements change, can quickly and easily morph into a mess of unmanageable code.
This is a problem we encounter often and was one of my main complaints the ASP applications that we were churning out. We can’t do anything about clients changing requirements, but we can do something about how we keep up with them.
A few points to take a away:
- Writing clean code is more important than you think.
- It often seems like a better choice to just get the app done, and worry about the details later. But later almost always requires more work.
- Test-first development is the way to go.
- The speaker is an agile development consultant and so he advocated test-first development, of course.
- It was pretty clear to me that refactoring becomes a lot easier, because you can do it with confidence, when you have tests that can ensure that your code still works.
- Improve code every time you check in.
- When you add some functionality to an app, make it a habit of always improving something else at the same time.
- A small investment of say, 10% additional work, every time you commit code, of improvement and refactoring of other code will go a long way to improving the app overall. Again, you can do this more confidently when you have tests.
- Reading other people’s code is a great way to learn.
- It was pretty interesting to read someone else’s code and learn how they would approach a problem. This is why things like Ruby Quiz are so helpful.
