Chapter 70. The Haiku Approach to Writing Software

Mitch Seymour

Haiku is a traditional form of Japanese poetry that follows a specific set of rules. Haiku are designed to evoke deep emotion or understanding by using only three lines and a fixed number of syllables. For example:

First autumn morning
the mirror I stare into
shows my father’s face.

Murakami Kijo

As my experience as a software engineer grows, I have found myself writing better software by approaching it as I would a haiku. Here are some of the lessons I’ve learned along the way.

Understand the Constraints Up Front

When we build software, we must often operate within a narrow set of constraints. The constraints may include the business requirements, the technologies at our disposal, the skill set or bandwidth of the team, and the time we’re given for actually creating the software.

Whether you’re writing a haiku or software, if you ignore or don’t understand the constraints of the project, you will have trouble producing what you set out to create. Instead of ignoring the constraints, aim to create something powerful or beautiful within them.

Start Strong Since Early Decisions Can Impact the Final Product

There’s a lot of freedom in the initial stages of a project. Many engineers approach a new project in the way a painter might approach a blank canvas. They lay down some initial, wild brush strokes in the codebase with the intent to return later and add more structure or detail. This painterly approach doesn’t always translate well, as the initial brush strokes often don’t get layered upon at all, but are instead annotated with TODO-style comments and become permanent fixtures in the codebase.

The haiku approach is to be careful and intentional with early decisions, so that they become a strong foundation for everything that comes after. In other words, don’t write the equivalent of the following haiku in your software:

Something something // TODO
the mirror I stare into
shows my father’s face.

Keep It as Simple as Possible

Unnecessary complexity can ruin a project. A haiku represents a body of work with all of the fat trimmed. Your codebase should be approached with the same care, as complexity threatens the long-term maintainability of your project and makes it easy for bugs to hide.

Simplicity is not always easy to achieve. In fact, it is often easier to write too much code than to find simpler, more efficient implementations. For the reasons I’ve stated, it’s worth the extra effort to trim this extra fat from your codebase and keep it as succinct and simple as possible.

Engage the Creative Side of Your Brain

Writing software is an art form. It requires creativity, good decision making, and a lot of hard work. If you are uninterested in the project or the medium, it will be reflected in the final product. If you allow yourself to be challenged creatively, as a haiku writer would, you will be giving yourself an opportunity to create something impactful for your customers or business while having fun in the process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.127.141