Scenario:
An application is going to perform operations on an entity. That means retrieving it from storage, possibly making modifications, and then persisting those changes back to storage.
I'm hearing conflicting approaches.
- We should retrieve an entire entity from storage (like a repository), our application logic should modify it (setting its properties or calling its methods, whichever) and then save the entire entity.
- We should only query the properties we need to execute application logic. When we save changes, we should have storage methods for saving only the modified properties. This will allow concurrent processes to update different properties without blocking each other.
This assumes a predominantly anemic domain model. It's more likely that application (domain) logic will read and set properties on entities.
I realize that no two scenarios are the same. What factors would you consider when deciding which approach to take?
I can't describe the actual scenario. Imagine building a network of computer technicians who work both on-site and remotely, determining who is available to work where and when and what their skills are, and deciding where and when you will assign them to work to match the expected need to schedule appointments. There are approval workflows involved for scheduling.
The result of errors might be things like scheduling someone for appointments in one area when they aren't going to be there, scheduling too many technicians in one area where there's not enough need, scheduling an on-site session for someone who works remotely, or scheduling an appointment with a technician who doesn't have the right skills.
A technician might say they're available but need to change it. Or their skills might change, affecting the types of appointments they can do.