2025 Public Training Schedule
January 14 – 17, 2025 – Agile Analysis and Design Patterns – Half-Day Sessions
(c) 2024 To Be Agile
Throughout this series of blog posts on story splitting, I’ve stressed the need to make our stories as small as possible. The way to do this is to keep a story focused on a single outcome for a single type of user with a single purpose.
Keeping the intentions of a story singular helps us build focused code around that story that is well encapsulated and straightforward to maintain. It also helps us create well-defined acceptance criteria for a story.
Cohesion is an essential quality of object-oriented software. It means that each and every piece of code is focused on a single intention. Every class has a well-defined intention, and every method also has a well-defined intention.
If we start to add additional behaviors to a class that are part of a different intention, then we dilute the meaning of that class. It can become “schizophrenic,” having one set of behaviors and a completely different set of behaviors that draw on different instance data. These are clues that tell us that there are really two classes in that single class.
One of the classes is typically hidden in situations like this and when we have hidden classes in our domain model it becomes distorted and difficult to discern. Instead, we want to make our classes about fulfilling a single intention and make each method of that class about fulfilling some functional aspect of that single intention.
This is how we use the tools of object-oriented software to communicate and build accurate domain models that are maintainable and extensible. By keeping intentions in our system clear, we remove redundancy in our code so that there is a single place for everything, and nothing is repeated.
Cohesion and all good code quality start before the code is written or even designed. It starts by building a good story, a story that’s clear and focused on a single intention.
Every story should be about achieving something, and just like we want to make the classes in our system focused on a single intention, we want to make our stories also focused on a single intention.
]When stories are focused on a single intention, we find that they end up being far more independent from other stories in a system, so that there is less coupling between stories and that they can be built independently and more easily integrated into the system. Focus stories yield better code, they are more understandable and more straightforward to verify.
Previous Post: « Minimize Dependencies
Next Post: Keep Stories Testable »