Sunday, May 26, 2013

Kata: "Birthday Greetings"

@CoGaNic and I have done the Birthday Greetings kata.
This kata is a simple refactoring exercise by Matteo Vaccari that is meant to teach something about dependency inversion and dependency injection. You can download the kata initial code from here.

We refactored it to decouple the domain objects from the file system and email sending code using the ports and adapters architecture as the exercise suggested. You can see the refactoring result on GitHub.

We think there's still room for improvement in the adapters code, but we are satisfied with how we manage to eliminate the initial coupling between domain objects and the infrastructure classes used to read files and send emails. Now the domain objects don't know anything about them.

All in all, it's been a great exercise. We've thought about dependency inversion and dependency injection (this great article by Brett L. Suchert helped us a lot: DIP in the wild) and clarified many doubts we had about the ports and adapters architecture, also known as, hexagonal architecture.

PS: Some time ago I posted some useful links about the ports and adapters architecture.

----------------------------

Update:
I revisited the kata some time after this post, recorded a screencast to document the refactoring process and wrote a new post about it.
Check it here.

No comments:

Post a Comment