Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
3-tier programming, Codebook, and business classes
Message
 
To
11/03/1998 04:58:27
Steve Camsell
Windmill Associates
Bath, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00083772
Message ID:
00084043
Views:
26
>A three-tier architecture looks like this:
>>
>>Tier 1: User Interface, Application logic
>>Tier 2: Business objects / rules
>>Tier 3: Data
>>
<snip>
>e.g. I have one called bizFindCustomer, which contains the functionality to allow the user to find and select a customer, whose ID it stores in an exposed property, for other objects to pick up. This object contains controls to allow the user to find the customer he/she wants i.e. a drop-down listbox to pick a search item, a textbox to key in search text and a listbox to display search results. Given that these are all part of the UI, is this a business object?
>
>If not, could anyone tell me what a true business object would be like for this particular example??

Steve,

Your class is misnamed as it is a user interface class. The actual business object might be called bizCustomer and it might have methods named FindCustomer and GetFieldValue. Your container might do something like this in its Init;


WITH THIS
.busCustomer = CreateObject("Business.busCustomer")
.busCustomer.InitializeData() && get the bus obj to set up its data
ENDWITH
<\PRE>

Assume there are some textboxes and one is txtPhone, in txtPhone's Valid you might;


IF THIS.Parent.busCustomer.FindCustomer("Phone",ALLTRIM(THIS.Value))
WITH THIS
.lstCustomers.Clear
.lstCustomers.AddItem(.busCustomer.GetFieldValue("Name") ;
,.lstCustomers.NewItemId+1,1)
.lstCustomers.AddItem(STR(.busCustomer.GetFieldValue("CustId")) ;
,.lstCustomers.NewItemId,2)
DO WHILE .busCustomer.GetNextCustomer()
.lstCustomers.AddItem(.busCustomer.GetFieldValue("Name") ;
,.lstCustomers.NewItemId+1,1)
.lstCustomers.AddItem(STR(.busCustomer.GetFieldValue("CustId")) ;
,.lstCustomers.NewItemId,2)
ENDDO
ENDIF
<\PRE>

Of course this code is demo only, but it does show that the actual business object has no UI at all. It retrieves and writes data only. It contains all the intelligence to know how to deal with the entity it represents. It can be used by VF or VB or Excel or anyother host for an ActiveX server and it will do the same thing. It is UI and data independent.

The business object provides for the UI to be data source independent by presetning a consistent interface to the data. In the example I only need to change code in the busCustomer class to change the data source form VFP to Oracle, the UI knows nothing about where the data comes from.

As an N-Tier design, if I change the code in the busCustomer class all applications that use that class now get their data from somewhere else. There is no need to change code in any application using the class.
Previous
Reply
Map
View

Click here to load this message in the networking platform