How To TDD Your Product Design

Test Driven Development (TDD) follows the RED => GREEN => REFACTOR cycle. You first write a test for the outcome you expect (RED), then write the code to make the test pass (GREEN), then go back and refactor your code to make it cleaner and DRY (take out any repetition).

Yesterday, I attended the Principles of Product Design Skillshare course taught by Quora Product Designer David Cole, and I was surprised to learn that TDD is very applicable (and necessary) for good product design. Here is what I learned from David Cole as applied to TDD principles:

The TDD Approach

A good product tackles only one problem at a time. In product design, you can innovate on product (invent something new), interaction (the touch screen on the iPhone was novel), or visual design (looks pretty). AirBNB is a perfect example of a product that got this right. They tackled the problem of innovating the product (booking spare rooms) while making their visual design and interaction very similar to hotel.com or other similar booking tools.

Once the problem you’re trying to solve is identified, it is important to build the product progressively – validating smaller pieces as you go to build a bigger picture. A great example of this is Apple. They first build the iPad and played around a lot with the touch screen interface, they then build iTunes as a separate application, and their brilliance came from putting these two smaller pieces together to create the iPod, then the iPhone, then the iPad. All their small ideas snowballed into making them into one of the most successful companies in the world.

With TDD, you are forced to focus on one problem at at time, which is broken out into much smaller pieces that end up emerging into a beautiful big product later on.

RED

While it is tempting to focus on the “how”, the most important thing to think about when designing a product is the outcome that you hope to achieve. Netflix, for examples, is focused on connecting people with movies they love. If they were focused on the “how”, they would be out of business in the next few years, as DVD by Mail is no longer the best way of connecting people with movies they love. TDD is very similar, as you test for the code’s return value instead of how the return value is achieved.

GREEN

David Cole talked a lot about approaching product design as a scientist. You have a hypothesis that you set out to prove in the beginning, have expectations of the outcome, and are prepared to be wrong.  It is important to test all your hypotheses, even the ones that seem “obvious”. Only facts can validate your hypothesis. With clear expectations of success, it is also easy to see which path works.

REFACTOR

David Cole was a big fan of designing for re-use. Once you know something is working (after you test it), you can re-use the same design elements and ideas. Once example of this is Twitter Bootstrap, which makes it easy for everyone to re-use design elements on their own website.

With TDD, once you get something to work, you go back and clean up your code so it’s DRY (not repeated). Most of the time this is accomplished by created a helper method that can be used in multiple other methods in your code.

Although TDD might be tedious, it is a really good mindset to get into, not just for development, but for pretty much anything else!

Enjoy the article? Join over 17,500+ Swift developers and enthusiasts who get my weekly updates.