Showing posts with label Ports and Adapters. Show all posts
Showing posts with label Ports and Adapters. Show all posts

Saturday, May 10, 2014

Saturday, February 22, 2014

Birthday greetings refactoring kata at Barcelona Software Craftsmanship: step by step commits and screencasts


We practiced refactoring and learned about ports and adapters using Matteo Vaccari's Birthday Greetings kata in refactoring mode. This is the initial code in Java that we tried to refactor.

I prepared several slides to introduce what we were going to do. I thought that we could just start refactoring for two hours right after this explanation, but, thanks to the suggestions of some attendees, we changed the plan and did two iterations (extracting the employees repository in the first one and extracting the greetings sender in the second one) with a retrospective in the middle.

This was a really good idea because it gave us the opportunity to debate about different approaches to this refactoring and about ports and adapters. Some very interesting points were raised during those conversations and we could exchange personal experiences and views about this architecture and refactoring. This kind of conversations are a very important part of practicing together and they enrich the kata experience.

I think I have a lot to improve as an event host. Next time I'll make explicit that attendees need to bring their laptop and I'll try to help more the beginners.

I had published a possible solution to the kata, but it was just the final solution not the intermediate steps. Some attendees said that they would like to see how this refactoring could be done in small steps. For that reason, I redid the kata again at home committing after every refactoring step and recording the process:
Take this recordings with a grain of salt because I'm still working hard to improve my refactoring skills.

Well I hope this might be useful to someone.

Just to finish, I'd like to thank all the attendees for coming, I had a great time. I'll try to do it better the next time.

I'd also like to thank netmind for their support to our community giving us a place and the means to hold Barcelona Software Craftsmanship events. Having a regular place for our events makes everything much easier.

So far the events have had much more attendees than we had expected. In fact, this last Monday we nearly run out of space. If this trend continues, we'll probably need to ask for a bigger room to hold future events.

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

PS: Christian Soronellas shared a version of the initial code in PHP.
Thank you very much Christian!

Thursday, February 20, 2014

Interesting Talk: "The Framework as an implementation detail"

I've just watched this interesting talk by Konstantin Kudryashov and Marcello Duarte:
They show how the framework (in this case Symfony) can become an implementation detail by using the hexagonal architecture.

Check also the example code they show at the end of the talk.

Monday, August 5, 2013

Interesting talk: "TDD, where did it all go wrong"

I've recently watched this interesting talk by Ian Cooper:
He talks about ways of avoiding common problems that arise when TDD is not practised well.

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.

Tuesday, September 4, 2012

Resources for Growing Object-Oriented Software Guided by Tests (GOOS)

I've been reading Growing Object-Oriented Software Guided by Tests during August. It's a great book.

I've also started to read some of the articles mentioned in the book and to watch talks in which the authors talked about some of the topics treated in the book. These links are included in several posts in this blog.

When I found out that there was a reading club with people interested in the book, the path11 book club, I thought that I could help by collecting in a single post all the posts containing related resources that I've posted so far.

So here they go:

I hope they will be useful.

Tuesday, August 14, 2012

Ports and Adapters

In Growing Object-Oriented Software, Guided By Tests its authors explain how they grow systems a slice of functionality at a time. As the code scales up, they need to structure the functionality so they can continue to understand and maintain it. They use two principal heuristics to guide this structuring:
  1. Separation of concerns.
  2. Higher level of abstraction.
They state that, when applied consistently, these two forces push the structure to something similar to Cockburn's "ports and adapters" architecture.

These are the links I'm reading to find out what this "ports and adapters" (or hexagonal) architecture is about: