3 layers

From: Alan (NOSPAMalan_pltse_at_yahoo.com.au)
Date: 04/30/04


Date: Fri, 30 Apr 2004 16:06:34 +1000

I think I had asked this kind of question but again I need to ask again:
An application has 3 layers:
presentation layer
business logic layer
persistent layer

I understand persistent layer responsible for connecting the database, read
and write the database.

For example:
TADOLayer = class
private
     //

public
    functionGetCustomerDataID(aBusinessObject: TCust_BO): Boolean;
end;

The question is if the parameter is business object, I can do the
followings:

function TADOLayer.GetCustomerDataByID(aBusinessObject: TCust_BO): Boolean
begin
    // execute the SQL and get the data
    blah blah balh
   // the assign the fields value to this aBusinessObject properties
   blah blah blah
end;

So in the presentation layer, like press a button:

procedure LoadCustomer;
var
  Cust_BO: TCust_BO;
begin
    Cust_BO := TCust_BO.Create; // create a business object instance
    if Cust_BO.GetCustomerDataByID(StrToInt(edit1.Text)) then
      with Cust_BO do
       begin
           // assign the properties of Cust_BO to the other edit boxes

       end;
end;

Now in the business object,

function TCust_BO.GetCUstomerDataByID(aID: Integer): Boolean;
begin
    fCust_ID := aID;
    Result := ADOLayer.GetCustomerByID(self);
end;

Is this a good approach ?


Quantcast