Domain Driven Architecture
One problem with early versions of opentaps is that the ofbiz framework which we used to develop it is not an object-oriented framework. Instead, it is based on a data model, which is fundamentally relational, and that data model is accessed via a map-like Java Object called GenericValue. Most of the services in the business tier used a GenericDelegator to retrieve GenericValues from the database, performed operations on them, and then stored them back into the database again using the same GenericDelegator.
While this is a very lightweight architecture from a perspective, as opentaps grew it became apparent that some of the application could significantly benefit from an object-oriented architecture. A few months ago, we started down this path and thought about how to write more object-oriented code with the ofbiz framework. More recently, after reading about Domain Driven Design, we realized that what we really needed was not just object-oriented code, but rather a more formal classification of our business tier into domains. This document explains what domain driven architecture is, how we have implemented it, and how it could help you structure your code.
What is Domain Driven Design?
The basic idea behind a domain is that it is used to group together all the "domain expertise," or business knowledge, of an application and separated from the application and its infrastructure. It is a different way of thinking about how to organize large software applications and complements the popular Model View Controller (MVC) architecture, which we also use in opentaps. With the Model View Controller architecture, the application's user interface (View) is separated from its business logic (Model), and a Controller directs requests from the view layer to the relevant business logic found in the model layer. The advantage of doing this is that the same business logic could then be reused elsewhere, either in another view layer page or as part of some other more complex business logic in the model layer.