Chapter 4 and 5

In chapter 4 Martin mentions some rules and principles for coding. Coding needs concentration and focus. Whenever you are tired or distracted do not code. If you code in that situation the code will be wrong and sloppy. Also writing code when you are worry about something is not a good idea, so before writing code try to resolve the worry. Some programmers feel that they are more productive and infallible when they are in the “Zone”. The problem of writing code when you are in the Zone is that you lose some of big pictures. Writing code in the Zone is faster but it will cause you to go over that code again to make changes. One interesting thing that Martin mentions is about listening to the music while coding. Some programmers listen to music while coding and they think that they have more concentration. But music is helping them to enter the Zone. Factors such as sleep deprivation, fear, and depression can cause blockage. In that situations the solution is to find a pair partner. Working with someone can help you to think better. When you are stuck and feel tired just step away, go outside, take a shower and try to clear your mind from everything.

Chapter 5 is all about Test Driven Development(TDD). Martin believe that all programmers should use TDD in their codes. He mentions that first write a failing unit test before writing any code. Then writing code to make it pass and repeat this cycle ­­over and over until the final product is achieved. For me writing test before writing code is very hard. But I think doing this will help us to have fewer bugs in our codes. Also when we have bunch of tests that we trust, then when we see bad codes we can clean them without fear. But using TDD doesn’t guarantee that you won’t have bad code.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s