Let's face it, change is the way of life. Inevitably, change is the way of software too.
In case of enterprise applications change is continuous. This comes in the form of new business requirements involving complex logic and changes to the interfacing systems.
Logic can change on its own and usually does not cause changes to interfacing systems.
But the other way round is a completely different story.
It is an extremely bad practice to let interfacing systems' scheme (classes and relationships) to propagate through your application. No one does that, no one should.
We depend on the use of Adapters, DAO and Value Objects that carry data through our applications and let our logic run on those.
Yet, one complexity lingers, how to safely and easily move from one interface to an alternate one. Say today our application uses a traditional relational database like Oracle and we want to replace it with a NoSQL database like MongoDB or Riak or Cassandra?
Changes to value objects is costly. An easy option is to build new adapter/DAO while reusing the value objects. This provides easy migration from one interface to another, but still causes the central business logic to change, where it needs to call a different set of adapters or DAO classes to build the VO.
The easy way out is, building your application using self building value objects. What that means is the value objects, know how to build themselves. The adapters/DAO shall be implemented as Strategies and the "building" of the VO, shall be a behavior of the VO, which is implemented by the "pluggable strategy". Furthermore, the choice of strategy can be delegated to a factory and thus made configurable.
The application logic instantiates DataBaseVO while passing the required instance of the DatabaseDAOStrategy. The identification of required instance can be done using a factory.
Once the VO is instantiated, the buildMe method shall be invoked which calls the buildDatabaseVO method on the strategy instance.
This can further be extended, as needed to invoke back ends asynchronously. The buildMe method can be replaced by implementation of run method, while DataBaseVO implements Runnable (or extends Thread). A flag determines whether the object is built or not. The central application logic can invoke retrieveData method to get completely built instance of the DataBaseVO.
So try this out the next time.
In case of enterprise applications change is continuous. This comes in the form of new business requirements involving complex logic and changes to the interfacing systems.
Logic can change on its own and usually does not cause changes to interfacing systems.
But the other way round is a completely different story.
It is an extremely bad practice to let interfacing systems' scheme (classes and relationships) to propagate through your application. No one does that, no one should.
We depend on the use of Adapters, DAO and Value Objects that carry data through our applications and let our logic run on those.
Yet, one complexity lingers, how to safely and easily move from one interface to an alternate one. Say today our application uses a traditional relational database like Oracle and we want to replace it with a NoSQL database like MongoDB or Riak or Cassandra?
Changes to value objects is costly. An easy option is to build new adapter/DAO while reusing the value objects. This provides easy migration from one interface to another, but still causes the central business logic to change, where it needs to call a different set of adapters or DAO classes to build the VO.
The easy way out is, building your application using self building value objects. What that means is the value objects, know how to build themselves. The adapters/DAO shall be implemented as Strategies and the "building" of the VO, shall be a behavior of the VO, which is implemented by the "pluggable strategy". Furthermore, the choice of strategy can be delegated to a factory and thus made configurable.
The application logic instantiates DataBaseVO while passing the required instance of the DatabaseDAOStrategy. The identification of required instance can be done using a factory.
Once the VO is instantiated, the buildMe method shall be invoked which calls the buildDatabaseVO method on the strategy instance.
This can further be extended, as needed to invoke back ends asynchronously. The buildMe method can be replaced by implementation of run method, while DataBaseVO implements Runnable (or extends Thread). A flag determines whether the object is built or not. The central application logic can invoke retrieveData method to get completely built instance of the DataBaseVO.
So try this out the next time.


Comments
Post a Comment