Today has been a special day. Not because it’s my 34th Birthday which I never really celebrate (although I do appreciate all the greetings and warm words from all my friends and family!) but because I’ve had the pleasure to spend the day working with Carlos Peix for the first time. Carlos is a well-known software craftsman from Argentina. It’s his first time in Spain and we are lucky that he chose us to spend two days working with us as part of his journey. It’s an exchange, something a journeyman does to learn and share. Among other things we have been mob programming today, refactoring code aiming to come up with a proper domain model. We have been identifying anemic models and data transfer objects trying to turn some of them into domain models. Trying hard to make up a good object oriented design. Things I like from Carlos’ suggestions today:
- Enumerate a list of all the classes we plan to refactor (or classes that are going to be affected) so as to be able to estimate how much time we are going to invest in this task and thus make a better decision on where to stop refactoring.
- Rather than refactoring every object in depth, apply little changes to all the objects visiting all of them to build a mental map of dependencies and structure. For instance, we decided we wanted to hide setters and create constructors to inject the attributes. Although a single class suffered from other smells, we performed only that change to it and moved to the others until all of them changed. To me it’s like exploring the tree breadth-first.
- Sequence diagrams help understand the complexity of the design. It’s funny that this should happen exactly at the same time I am reading Sandy Metz’s book on OOP. Carlos hasn’t read the book but he recommends the same technique than Sandy Metz. The sequence diagram was an “aha” moment to my colleague Miguel.
- We commented on the different strategies to expose an object to different bounded contexts, using interfaces and using wrappers. We didn’t have much time to dig into it.
- Repositories retrieve aggregates when possible, that is rich domain models rather than anemic models.
Looking forward to more synergy tomorrow, it’s been an exciting day.
And you fellow journeyman, remember that we are open minded and value your visit to our office. If you want to work with us for a few days drop us a line, we look forward to it!