Upload
mrinal
View
27
Download
0
Embed Size (px)
DESCRIPTION
Basic Three-tier-application-building. Session V18. Rainer Becker. dFPUG, Germany. Who Am I?. German FoxPro User Group http://www.dfpug.de/forum German VFP DevCon FoxX Professional Wizards & Builders GmbH http://www.wizards-builders.com MVP, MCSD, speaker/writer - PowerPoint PPT Presentation
Citation preview
FoxTeach 2001
Basic Three-tier-application-building
Session V18
Rainer BeckerdFPUG, Germany
FoxTeach 2001
Who Am I?
• German FoxPro User Grouphttp://www.dfpug.de/forum
– German VFP DevCon– FoxX Professional
• Wizards & Builders GmbHhttp://www.wizards-builders.com
• MVP, MCSD, speaker/writer– But I am not bilingual !
FoxTeach 2001
Who are you?
Visual FoxPro Programmers trying to match the capabilities of the
tool against a confusing number real world request
FoxTeach 2001
Remember Windows DNA99?
HTMLHTML
WindowsWindows
ActiveActiveDocDoc
Client/ServerClient/Server
lokal tableslokal tablesCOM-ServerCOM-Server
COM-ClientCOM-Client
XML-transferXML-transfer
FoxTeach 2001
Basic Theory
The minimum of theory
(you might know already)
FoxTeach 2001
Access in/between Layers
• Within a tier, “no limitation“– Do not forget delayed instantiation
• Between tiers, limited access– “strict“– “linear“– “tree-structured“– Variant: “partially not transparent“
FoxTeach 2001
Example for linear structure
• Advantage: Every tier can be replaced
• Disadvantage: Every tier has compl. Interface Every tier visited on the way down
Application
Presentation
Session
Transport
Netw ork
Data Link
Physical
OSI 7-Layer Model
http - ftp - mail - telnet
TCP
IP
Data Link
Physical
TCP/IP Protocol
FoxTeach 2001
Example for strict structure
• VFP-interface with databinding
• Advantage: Faster to develop, more performance
• Disadvantage: Business tier can be bypassedData navigation problems
FoxTeach 2001
Words and Tiers
Important Words
• Request
• Notification
• Cache
Typical Tiers
• User Interface
• Business Logic
• Database
FoxTeach 2001
Replace Front-End
• No direct application access or• „Web Glue“ (=redundancy!)
FoxTeach 2001
Replace Backend
• No native record-locking• “Properties“ for each data field• “Views“ for each list
User interface app. logic logical DB physical DB
FoxTeach 2001
Replace Front- and Back-End
FoxTeach 2001
The only thing not changing?
• Your business logic is the only thing thats going to be re-used in all environments
• The „wall“ between GUI and BO gives wrong idea
FoxTeach 2001
Basic Implementation
Coding the first set of classes
FoxTeach 2001
Top-Down Implementation
• User interface layer– Unified GUI-superclass– GUI-classes, especially buttons
• Business object layer– BO-wrapper– Business logic and service classes
• Data Access layer– Data intermediate layer– Data access layer
FoxTeach 2001
Start the Application
• Base_Base– Just geterrortext
• Loader_base– Check_path, set_path (.cPath),
load_vcx (.cvcx), start_menu (.cmenu), program_end
• Small main program for class-libs and creation of loader class
FoxTeach 2001
Basic GUI Layer
Beware – it‘s a VFP-GUI !
FoxTeach 2001
GUI Baseclasses
• Usual interface classes - example reduced to:button, combo, form, label, spinner, textbox, toolbar
• Super-Baseclass for various redundant GUI methods– E.g. Init, got/lostfocus, rightclick
FoxTeach 2001
GUI Buttons
• Add, Delete, Save, Restore, First, Last, Next, Prev, Quit
• Button-group to be placed on form
• Toolbar with all buttons– Init to distinguish form / toolbar – Toolbar: height/width=23, caption=„“– Button: picture = „“
FoxTeach 2001
GUI Button Functionality
• cBO, cBOMethod, lEnableWhenChanged
• Click– GetBORef( .cBO ).&cBOMethod
• Refresh: If ! Isnull() = TripleLogic– GetBORef( .cBO ).IsChanged()
= .lEnableWhenChanged
FoxTeach 2001
.GetBORef( .cBO ).<method>
• GetBORef[1,0] is an array property with an access method
• BO-name arrives as a parameter• Call is forwarded and returns a
reference to a BO• Method-call can be added
– Can again call an array
• This is our tiny BO-wrapper
FoxTeach 2001
Toolbar
• Toolbar Manager Methods– Create, Destroy, Hide, Show,
Refresh
• Management by form– Init, Destroy, Activate, Deactivate,
Refresh
• Form additionally refreshs label– Setall lRefresh, assign calls refresh
FoxTeach 2001
Additional Form Methods
• QueryUnload important for unsaved data– Query all business objects on form
• Release has to call queryunload
• By the way: Place everything in a container, not on the form itself!
FoxTeach 2001
Business and Data Objects
First view on similarities between these layers and small
implementation to start with
FoxTeach 2001
Business Logic Layer
• Forwarding methods to Data Access Layer for persistence– Add, delete, first, next, last, prev– save, restore– ischanged– Returning return value
FoxTeach 2001
Data Access Layer
• Tablemove– add, delete, first, last, next, prev
• Tablework – save, restore
• Serviceclass for Open– Table, alias, order, readonly,
buffering
FoxTeach 2001
Business Logic
How and where to place the logic? Some side effects on database
and user interface...
FoxTeach 2001
Validation and Action
• User interface needs validation status without triggering resulting actions
• Validation and resulting action belong to different methods
• Multiple change reactions kill each other (“record-valid“-type logic)– time-based price list and parts list– Change gender/dates in medical
insurance
FoxTeach 2001
Placing redundant Logic
• Associate general functionality
• Aggregate services and cascade calls to them
• Use a service factory for alternate rule-sets
• Moved to separate session about aggregation vs. subclassing
FoxTeach 2001
Status Information
• Invalid records should be saved persistently
• Valid status of record depends on its role– Even more so in logical tables
FoxTeach 2001
Pointer Position
• Data-binding of VFP connects GUI with DATABASE– So you are “strict“, not “linear“, at
least for displaying information
• Business logic moves around in data and makes pointer position an important “state“ to restore
FoxTeach 2001
Performance Problems
Advantages in maintenance against reaching performance
expectations
FoxTeach 2001
Stateless and small
• Web servers / transaction servers love stateless, independent small objects
• Complex objects / business logics are seldomly stateless or independent– A large number of small objects is not
small any more by any means
• Not being stateless increases the loads of the business logic and the data tier
FoxTeach 2001
Delayed Instantiation
• You can delay instantiation not only for pages but for all tiers, but:
• “See everything“-interfaces (like „*“ in Client/Server) / complex calculations load everything at once
• interface therefore at least under performance aspects not really “independent“ from business logic
FoxTeach 2001
Generic “Treeviews“
• Complex hierarchical data does not allow for in-between-layers on any “available“ hardware
FoxTeach 2001
Conceptual Problems
Each tier has its own unanswered logical questions
FoxTeach 2001
Somehow Redundant Rules
• Interface– Default value, picture, enable/disable,
popups
• Business Logic– Cannot expect correct parameters due to
COM Server access without interface
• Data– Default value, Field valid, record valid,
calculated fields, referential integrity
FoxTeach 2001
Data Access in general
• Number of “standards“(ODBC, RDO, DAO, ADO, OLE-DB, ...) gives a hint to a real problem
• Access rights allow direct writes to database - bypassing business logic
• Read rights do not give any logical functionality or “sense“
FoxTeach 2001
Web Interface to different
• Field validation needs permanent fast access to web server
• Large lookups need high-speed connection or local table
BTW: Have you ever seen XML for data input forms and/or with basic validation definitions?
FoxTeach 2001
How to prepare for Multi-Tier?
If standards and designs change, how can I prepare my architecture
in a somehow stable way?
FoxTeach 2001
User interface depends on environment
• Interactive Interfaces– Windows Styleguide– Instantiated COM-Server
• Disconnected environment– Processing FOXISAPI-hit– Processing XML in WebService
FoxTeach 2001
Implementation depends on interface
• Single-Field-Validation– For interactive User Interface– For COM-Server
• Complete-Record-Validation– For Internet Access– For Web-Services
• You have to implement both!
FoxTeach 2001
Something has not changed...
• OLE, COM, COM+ (and maybe SOAP) is still the same basic concept...
• Provide an additional interface for disconnected environments
FoxTeach 2001
Additional Material
Where to go from here ? Where to find additional information ?
FoxTeach 2001
Companion CD
• Bo_base.vcx
• Gui_base.vcx
• Gui_button.vcx
• Reise.vcx (application example)
• Reise.dbc
• Reise.scx
• Reise_main.vcx
FoxTeach 2001
Visit other Sessions
• V12 “Developing N-Tier Applications with VFP” – Jim Booth
• V14 “Building World-Class Visual FoxPro COM Servers“– Kevin McNeish
FoxTeach 2001
FoxTeach Web Update Page
www.dbcentral.com
This session will have web updates. There will be a newer version of the code examples with heavy use of constants (see session V16).
FoxTeach 2001
Thank you!
Please remember to fill out your evaluation.