Business object is simply the object wrap up the data object and relationship of the data objects. The purpose of having another object to represent the business logic is to have loosely coupled object design.
Consider we have 2 data classes, Transaction and Product which both represent transaction table and product table in database. The relationship of them is defined as Transaction has none or more Product. Operation in between can be seen as Transaction add or remote Product.
So, we define a business object called BoTxn.
class BoTxn{
 private Transaction mTransaction;
 private ArrayList mProductList;
 
 public class BoTxn(String txnID){
   mTransaction = new Transaction(txnID);
   mProcductList = new ArrayList();      
 }
 public void setTransactionTime(DateTime dt){
  Transaction.setDateTime(dt);
 }
 public void addProduct(Product Prd){
   mProductList.add(Prd);
 }
 public void removeProduct(int index){
   mProductList.remove(index);
 }
 public void submitTransaction(){
  //update to database
 }
}
  
Some sample methods are shown above. We could have another class Customer, for example, to be in the BoTxn. The same relationship and operation could be built for Customer and BoTxn. The following code shows how to use in the code.
BoTxn txn = new BoTxn(1); txn.addProduct(new Product(1)); txn.addProduct(new Product(2)); txn.submitTransaction();On top of the relationship modelling above, I would like to share another modelling in data object in next post.