Process Object Pattern

Most application domains are chock full of processes. Sometimes they masquerade as transactions, until the requirements are elaborated and we discover that there are discrete steps and states involved.

If we start from day one modeling business processes as first-class elements in our domain, we get a couple of benefits. We still have a place to put logic to handle user actions. A place where it won’t bloat up our principle domain models, things like “User” or “Product”. But when it comes time to add more intermediate steps to these user activities, objects modeling processes can grow organically to accommodate the new logic. They can be queried for their current status at any time. And if necessary, we can even factor out subprocess objects to keep long, involved processes from becoming fat models in their own right.