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

7 Feb 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.


Helper Methods

21 Feb 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.


Use Standard Library Features

28 Feb 2016 code-gardening

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


Intention Revealing Method Names

20 Mar 2016 code-gardening

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


Use Full Words, Not Contractions

27 Mar 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.


Document Every Member

10 Apr 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.


Validate Method Arguments

16 Apr 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.


Boolean Parameters are Evil

15 May 2016 code-gardening

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


Multiple Boolean Parameters are Really Evil

22 May 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.


Throw Rich Exceptions

11 Jun 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.


Why Code Garden?

25 Jun 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.


Intention Revealing Bools

2 Jul 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.


Don't work too hard

30 Jul 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.


Null arguments are evil

14 Aug 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.


Are Boolean Return values Evil?

11 Sep 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().


What is it with Booleans?

8 Oct 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.


Method Archetypes

15 Nov 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.


Related posts

Semantic Types in C#6  27 May 2016