Code doesn’t matter

Have you ever noticed that making code beautiful isn’t that hard once you know what it is supposed to do? When the problem is well defined, there is very little difficulty in changing the solution to be more elegant. Take the problem of sorting, for instance. There are all sorts of elegant solutions built over many years for sorting just because the problem is pretty simple and well understood. But try entering into the realm of business apps instead and you’ll see a lot of ugly code.

Business apps programmers can’t make their code beautiful because most of the time they don’t really know what to build. Sure they need to study a lot about coding and master the latest coding techniques, but they don’t stand a chance if they don’t know what they’re building.

The real and hard work in software development is figuring out what the hell the customer needs, not programming the computer to solve it. If you want to use an waterfallish word, the hard work is figuring out the requirements. In fact the whole Agile thing is about getting the needs right. That’s why we strive to deliver early. That’s why we work iteratively. That’s why we value working software. After all, software is not working software unless the requirements are right.

By the way, working software is an interesting topic in itself. You can try to understand the customer needs using schematics, diagrams, use case documents or even with a cardboard poster hanging in the development team room.

Or you could use good old working software…

When the software is minimally ready — when it is at least working — customers can see what is does and ask for changes where needed. They can’t do that with use cases because they can’t see use cases working. It can even be worse: they can look at the schematics (that don’t work either) and think that it will work in a different way than what the team really meant.

Plain old software can be seen as a requirement gathering tool too. We fortunately are writing computer software, not building schematics. We don’t need to wait for the building to get done, we can run a compiler and our programs are ready to run. Civil engineers cannot tear their buildings apart and start all over again, so they invest a lot of time in getting the specs right before they start building. Programmers can destroy their buildings and rebuild them again as easily as saying make clean && make. Instead of wasting our time with dead documents, we can work with the real living thing. That’s why they call it software, exactly because it’s pretty easy to change. Not taking advantage from this flexibility is just dumb.

The logic goes pretty much like that. Code doesn’t matter because the most valuable work is the requirements work. Requirements work is really about figuring out customer needs. Figuring out customer needs is much easier when you have working software to show them. Working software needs code. Thus, code matters.

Well, code alone doesn’t actually matter, but it is your most valuable tool for understanding requirements.

BTUF

No, you don’t need to read the title again, you are not mistaken. It really is a T instead of a D (or R, depending on where you come from). BTUF is the acronym for Big Testing Up Front. BTUF is basically what happens when people try to write all conceivable tests before starting to code. With the rise of Test-Driven Development this is an obviously ascending waterfall practice.

Testing is also designing. When you write the tests before the production code in good TDD style, what you essentially do is to design how the code will look from the outside. Sometimes it may be hard to resist the temptation to design everything before writing a single line of code, specially for those used to waterfall thinking. For those who can’t help doing it, here is some news from yesterday’s paper: it doesn’t work. Even though everybody minimally informed has already heard it, this message never gets said enough.

It doesn’t work because designing is infinitely better and easier when we can have fast feedback. Software development can easily be a high feedback activity. Architects need to wait for the construction team to finish the piece and film writers sometimes need to wait years for the shooting to finish, but programmers can just compile their programs. Giving up this feedback on purpose is not the smartest thing to do. Writing all tests for a piece of code before starting the code itself is no different than drawing rectangles and arrows describing it in full detail before trying to make the whole think work. The risk of over-engineering is the same because the code isn’t there to scream in agony.

The key to avoid BTUF is writing the tests that you can come up with before writing the code to make them green, but making sure not to think too much. You can wait to start writing the code after all tests are in place, but you don’t need and neither want to.

TDD has shown us that design isn’t made only of diagrams. In fact, we are designing all the time we are developing software. TDD is only one of many design techniques: one that uses tests. It may be a better tool than arrows and rectangles in some situations, but is still just an approach for design. BTUF is, therefore, just an special case of BDUF where tests are used to determine the design completely before writing a single line of code.

Greetings

Enjoy Chaos is the English companion for the Portuguese blog Mergulhando no Caos. Sometimes you just feel that something sounds betters in English and this is why this blog got started. Some translations for my old texts will probably pop here from time to time, but I do intend to write some exclusive content for this blog. Sometimes the inspiration muse whispers in English and I don’t want to lose those opportunities.

Here I intend to talk about pretty much everything that interests, entertains and amuses me on the technology arena. I am a programmer and you should expect to find many articles here about my software development endeavours, but I will occasionally write about hardware and gadgets too.


Categories