Code Gardening is the practice of making small improvements as you see them while you are working, even if they are not directly connected to the feature or defect you’re currently addressing.

Tidying things up as you go is never wrong - just ask any gardener or that friend of yours with the immaculate house.

Tidy esthetic code is provably easier to read, easier to understand and easier to reason about.

Most importantly, you should be gardening because code can be beautiful … and it should be.

An Introduction

Sunday, February 07 2016 code-gardening

Code Gardening is the practice of making small improvements as you see them while you are working, even if they are not directly connected to the feature or defect you’re currently addressing.

Read more »

Helper Methods

Sunday, February 21 2016 code-gardening

Create helper methods to capture key concepts, even if they are only one line. Giving these concepts a meaningful name helps people reason about the rest of the code.

Read more »

Use Standard Library Features

Sunday, February 28 2016 code-gardening

Objects and methods in the standard libraries doesn’t need to be written nor debugged.

Read more »

Intention Revealing Method Names

Sunday, March 20 2016 code-gardening

Names for method should say what they do, but not how they do it.

Read more »

Use Full Words, Not Contractions

Sunday, March 27 2016 code-gardening

Use Full Words for concepts, not codes or abbreviations. This is the fifth in a series of posts on Code Gardening - the practice of making small improvements as you see them while you are working.

Read more »

Document Every Member

Sunday, April 10 2016 code-gardening

Write documentation comments on every method, every member. Well written documentation comments make it easier to understand the intent of the code that you’ve written. This will assist any developer who comes along after you - which might just be you, in six months time.

Read more »

Validate Method Arguments

Saturday, April 16 2016 code-gardening

Validate the arguments provided to all methods. Everyone knows that good diagnostics make it easier to troubleshoot issues - validating method arguments at the start of a method gives you an opportunity to detect issues earlier, and to give better information.

Read more »

Boolean Parameters are Evil

Sunday, May 15 2016 code-gardening

Boolean method parameters are evil. We use boolean values all the time - they are extremely useful.

Read more »

Multiple Boolean Parameters are Really Evil

Sunday, May 22 2016 code-gardening

Having multiple Boolean method parameters is a really really evil thing to do. In last weeks post we discussed how boolean parameters are evil and what can be done to rectify the issue.

Read more »

Throw Rich Exceptions

Saturday, June 11 2016 code-gardening

Throw Rich Exceptions that are thoroughly informative to allow easy fault diagnosis. System failures are inevitable. When something does go wrong, your code has one final responsibility - to leave enough diagnostic information to allow someone to work out what happened.

Read more »

Why Code Garden?

Saturday, June 25 2016 code-gardening

Somebody asked me the other day why I thought code gardening was so important - why had I invested my time in this series of blog posts and in a live coding presentation that I’ve given multiple times. That question turned into an interesting conversation and I thought I’d share one of those ideas with you.

Read more »

Intention Revealing Bools

Saturday, July 02 2016 code-gardening

When you have any non-trivial condition - whether in an if, while or until statement - move the condition into a well named local bool variable to aid in readability. This is another in my series of posts on Code Gardening - the practice of making small improvements as you see them while you are working.

Read more »

Don't work too hard

Saturday, July 30 2016 code-gardening

Don’t write more code than is necessary to get the job done. It can be very easy to write too much code. There are a lot of reasons why this might happen; the important thing is to recognise code like this when you see it and to fix the problem on the spot.

Read more »

Null arguments are evil

Sunday, August 14 2016 code-gardening

Don’t pass null as an explicit argument into a method. The problem with passing null as an explicit value into a method is very similar to that of passing explicit bool values into a method - the code is fundamentally unreadable.

Read more »

Are Boolean Return values Evil?

Sunday, September 11 2016 code-gardening

If you’re tempted to write a method with a boolean return type, consider whether another design might be more appropriate. One classic illustration of the problem with boolean return values can be seen in the standard .NET framework method int.TryParse().

Read more »

What is it with Booleans?

Saturday, October 08 2016 code-gardening

Given some of my recent blog posts, such as “Boolean Parameters are Evil” and “Multiple Boolean Parameters are Really Evil, it might seem that I have some kind of personal vendetta against booleans.

Read more »

Method Archetypes

Tuesday, November 15 2016 code-gardening

Follow method archetypes to constrain your method design to avoid surprises and simplify your design. This is another in my series of posts on Code Gardening - the practice of making small improvements as you see them while you are working.

Read more »

Related posts

Semantic Types in C#6  27 May 2016