Let's say that you want to create a model of a bank account in your application. You could create a class BankAccount that does what a typical bank account does. But if you're asked what the responsability of the class is, what's the answer? 'Behaving like a bank account?' That's not very concrete. I'm a bit confused on the relationship between modeling and responsibility. Many 'real world'-objects don't seem to have a clear responsibility.
What's the best way to start modeling such concepts and keep well-defined responsibilities?
Take apart what "behaving like a bank account" means. A bank account might need to be able to:
From this, you can abstract (refactor) some of these tasks (responsibilities) into more general models, e.g. "an entity that can be authenticated to at different levels of privilege", "an entity that can communicate with other entities of its type at the appropriate privilege level", "an entity that can record when its state changes and what change occurred", and so on.
Figuring out what the tasks are is what user stories are for, in the Agile development model. You don't have to drink the Agile kool-aid in order to use this technique, though; it's simply a sensible way of figuring out what a project's requirements are. Critically examining how users will interact with your software, and concretely defining what those interactions will do, is the first step in architecting the software.
Bank account responsibility examples, off the top of my head:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With