Creating Business Objects
Â
Â
While creating an application, very often we may come to situation where we have to add logic related to our business model. (By business I mean any logical operation pertaining to the needs of two interacting systems.) How to model our business objects? Usually, we create objects to fit to a model suiting our business needs. If we are creating these objects, it would make more sense, if we separate these properties from hard coded class and instead read and load from a metadata, e.g. using a database or an XML. It makes sense to make them loosely bound to the system. This should be done to insure that we are not hard bound to our code base for creating newer database objects or modifying an existing one. For example, in a standard implementation, we may have a DB Object that handles all database related queries and other classes extend this class. For example, a User class may extend the DB Object class. This class may dictate the way the user might behave in our application. This way, to create a new DB Object, we will need to create a new class. This doesn’t sound very flexible. Instead of this, if we develop a language (a standard to interpret metadata) within our framework to read and write DB objects, then we may be able to create objects as modeled in metadata. If these objects can be defined in database or an XML, we may load the metadata and load the DB Object accordingly. This also means that the properties of the object have to be defined in the metadata. Then what does the base DB Object do? Hide the complexities of the database behind the scene. As a part of platform it should be able to handle all the technology related implementations.
Broadly speaking, it leads us to the concept of two layers, of technology and of business. Usually, we may be tempted to intermix and use both in a single layer. Such a system will tend to be hard bound. On the other hand, the separation of the two layers gives us the flexibility to add business logic using metadata and build the platform enabling us to read and write it.
External links:
http://www.artima.com/weblogs/viewpost.jsp?thread=115101Â by Bruce Eckel