EXPENSE REPORT KATA

Today I was introduced to a new kata - The Expense Report! https://github.com/christianhujer/expensereport Being in the corporate world, sounds like a good kata to give a go. I'll be doing it in C#, shocker, I know. The process of the kata is laid out as follow…

Refactor Money with TDD - 04

Still Green; Keep Refactoring Let's take another look at Money;  there's eight methods. Five of these methods delegate the work to another object, "I know what I want, you know how to do it". The remaining three don't. To make "Similar things more similar" we have to consider refactoring these…

Refactor Money with TDD - 03

GET TO THE PRIMITIVE While we very much want to avoid data flowing through our system, sometimes we need them. Sometimes we have to get back to a primitive type. This happens at the boundaries of our system. When our code passes to some other code, we probably have to…

Refactor Money with TDD - 02

No Primitives - Again Since we're poking around the ExchangeRates area, one thing has stood out to me. public interface IExchangeRateTo { double To(Currency currency); } This interface has a method that returns a double... a Primitive. That's ... Nooooooo! What can we do to fix this? Clearly a type of somekind.…

Refactor Money with TDD - 01

BONUS TECHNIQUES Let's look at some bonus techniques I use when working in projects. * PrivateCtor - Utility class to access private constructors * No Primitives - Exchange Rate returns a double * MicroObjects - We haven't hit the size limit yet; let's explore that. * ToSystemType - Not mentioned during this, but a…

Make Money with TDD - 08

No Primitives I'm VERY against primitives' being passed around in a system. As soon as I started putting in hard coded strings of the currency I knew it'd have to be extracted out into something that's not a primitive. I didn't do this earlier because it wasn't being asked for…

Make Money with TDD - 07

I'm Not Adding As mentioned, What about converting between currencies without adding currencies together? That seems like it'll be a useful thing for our system. Let's mark that as our current work in progress! > 5 USD * 2 = 10 USD 10 EUR * 2 = 20 EUR 4002 KRW / 4 = 1000.5 KRW…

Make Money with TDD - 06

Cross Equality The requirement we want to get to now is to allow our equality to work across currencies > 5 USD * 2 = 10 USD 10 EUR * 2 = 20 EUR 4002 KRW / 4 = 1000.5 KRW 5 USD + 10 USD = 15 USD 5 USD + 10 EUR = 17 USD 12 USD == 10…