Saturday, May 3, 2014

Kata: Revisiting Gilded Rose in Java

Yesterday Jaume Jornet and I were practicing together doing the Gilded Rose kata in C#.

At the end of the session, we left the code in a point where it was ready to substitute several conditionals with polymorphism. Then we discussed how we would do it without modifying the Item class (to avoid the goblin's rage).

We talked about wrapping Item in another object DegradableItem and then create several subtypes for it. Once having this design in place the Conjured items might be implemented using a decorator over DegradableItem.

When I got home I did the whole kata again in Java and coded these ideas we had talked about with some slight variations:



You can compare it with another version I did nearly a year ago.

Our lifes would be much easier without the goblins :)

No comments:

Post a Comment