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.

Killing the utility class with relocation

Saturday, January 20 2018 code-gardening

Sometimes you’ll find a method on your utility class that’s only used once - or only from a single consuming class. This frequently happens when a developer genuinely believes the method will be generally useful and should be available for reuse, but is wrong.

Read more »

Killing the utility class with consolidation

Saturday, January 13 2018 code-gardening

Sometimes your utility class will contain methods that smell strongly of feature envy, prompting you to relocate them onto an existing class. This is a much simpler cleanup than introducing a semantic type.

Read more »

Killing the utility class with semantic types

Saturday, January 06 2018 code-gardening

Following on from our discussion on extension methods, another technique you can use when eliminating the dumping ground of your utility class is the extraction of buried semantic types. This is possible when you find a set of closely related methods with linked semantics.

Read more »

Killing the utility class with extension methods

Saturday, December 30 2017 code-gardening

Think about the larger projects you’ve worked on during your career. Did you have a dumping ground for odd pieces of functionality? Perhaps a utility class or even multiple multiple utility classes? It’s a very common thing to see a utility class in any codebase of reasonable size, especially one that has been around for a while.

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 »