Skip to content

danparkin.com

Software thought soup

November 17, 2018

Object-oriented Fizz Buzz

I was having some fun with the FizzBuzz kata and wanted to share an object-oriented (OO) solution I was playing about with. I wanted to see what FizzBuzz would be like if a number range and each rule were objects. If you’ve done FizzBuzz before then I’m sure you’ve seen something along the lines of the following which is a typical...

Categories Software Design Comments: 0
October 17, 2018

Hide Delegate

In this post I want to talk about the refactoring Hide Delegate. I was prompted to write this by some code I reviewed around the time of writing this post where there were a number of instances of objects that were leaking their internal state. I did a post on Tell, Don’t Ask and what I saw in the code review got...

Categories Code Smells Comments: 0
October 14, 2018

The Single Level of Abstraction Principle (SLAP)

In this post I’m going to talk about giving methods a good slapping! The Single Level of Abstraction Principle (SLAP) tells us that each method should work at a single level of abstraction, but what does that mean? Let’s look at the following code that prints out the numbers 1 to 35 to console. Yes it’s awful and nonsensical but...

Categories Software Design Comments: 0
September 30, 2018

What Is a “Unit” in Unit Testing?

In this post I want to talk about how a unit in unit testing refers to “a unit of behaviour”. I was prompted to write this as I saw a discussion on Twitter about the topic but it felt particularly topical for me as I had fallen foul to what was being discussed on the Twitter thread in the days...

Categories Test Driven Development Comments: 0
September 18, 2018

Tell, Don’t Ask

In this post I’m going to look at the principle of Tell, Don’t Ask. The reason I wanted to write this was because for the longest time the naming of it confused me. I’d see objects asking things of other objects all the time and for whatever reason it was a square peg round hole situation for me. It wasn’t until...

Categories Software Design Comments: 0
April 26, 2017

Time to Roll Your Own Type

Normally when you’re working with a framework or language you assume that the library it ships with will provide types for most of your basic needs, and this is what I’ve always thought about the .NET framework. When you’re working with a .NET language you have access to a very rich set of libraries, covering all sorts of different functionality,...

Categories Software Design Comments: 0
April 20, 2017

Helpers, Utils and Hot Spots

In my last post I talked about the danger of having classes with names that end in “helper”, “util”, “impl” in your codebase and how you should avoid them. To carry on with that topic I’ve found some, albeit loose, evidence that visualises the phenomenon and supports my claims. I came across a fantastic book called Your Code as a Crime Scene by Adam Tornhill which...

Categories Code Smells/Refactoring Comments: 0
April 12, 2017

Helpers, Utils and Swamp Thing

Have you ever come across a class in a project you’ve been working on with something like “helper”, “service” or “util” in the name? Unless you’re one of the fortunate few who’ve never had to regularly have a steaming hot plate of spaghetti code for your breakfast, lunch and dinner, then I’m guessing you have. Do you remember if that...

Categories Code Smells/Refactoring/Software Design Comments: 0

Search

Tags

C# (1) Clean Code (1) Code Smells (5) Design (6) Design Patterns (1) Principles (1) Refactoring (5) TDD (1) Unit Testing (1)

Categories

  • Code Smells (3)
  • Refactoring (2)
  • Software Design (5)
  • Test Driven Development (1)

©2019 danparkin.com

Coldbox WordPress theme by mirucon

  • Twitter
  • Linkedin
  • GitHub
Back To Top