Basic three tier application building
This presentation is the property of its rightful owner.
Sponsored Links
1 / 48

Basic Three-tier-application-building PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Basic Three-tier-application-building. Session V18. Rainer Becker. dFPUG, Germany. Who Am I?. German FoxPro User Group German VFP DevCon FoxX Professional Wizards & Builders GmbH MVP, MCSD, speaker/writer

Download Presentation

Basic Three-tier-application-building

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Basic three tier application building

Basic Three-tier-application-building

Session V18

Rainer Becker

dFPUG, Germany

FoxTeach 2001

Who am i

Who Am I?

  • German FoxPro User Group

    • German VFP DevCon

    • FoxX Professional

  • Wizards & Builders GmbH

  • MVP, MCSD, speaker/writer

    • But I am not bilingual !

FoxTeach 2001

Who are you

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

Remember Windows DNA99?

lokal tables









FoxTeach 2001

Basic theory

Basic Theory

The minimum of theory

(you might know already)

FoxTeach 2001

Access in between layers

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

Example for linear structure

  • Advantage: Every tier can be replaced

  • Disadvantage: Every tier has compl. Interface Every tier visited on the way down

FoxTeach 2001

Example for strict structure

VFP-interface with databinding

Advantage: Faster to develop, more performance

Disadvantage: Business tier can be bypassedData navigation problems

Example for strict structure

FoxTeach 2001

Words and tiers

Words and Tiers

  • Typical Tiers

  • User Interface

  • Business Logic

  • Database

Important Words

  • Request

  • Notification

  • Cache

FoxTeach 2001

Replace front end

Replace Front-End

  • No direct application access or

  • „Web Glue“ (=redundancy!)

FoxTeach 2001

Replace backend

Replace Backend

  • No native record-locking

  • “Properties“ for each data field

  • “Views“ for each list

User interface app. logic logical DBphysical DB

FoxTeach 2001

Replace front and back end

Replace Front- and Back-End

FoxTeach 2001

The only thing not changing

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

Basic Implementation

Coding the first set of classes

FoxTeach 2001

Top down implementation

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

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

Basic GUI Layer

Beware – it‘s a VFP-GUI !

FoxTeach 2001

Gui baseclasses

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

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

GUI Button Functionality

  • cBO, cBOMethod, lEnableWhenChanged

  • Click

    • GetBORef( .cBO ).&cBOMethod

  • Refresh: If ! Isnull() = TripleLogic

    • GetBORef( .cBO ).IsChanged() = .lEnableWhenChanged

FoxTeach 2001

Getboref cbo method

.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 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

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

Business and Data Objects

First view on similarities between these layers and small implementation to start with

FoxTeach 2001

Business logic layer

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

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

Business Logic

How and where to place the logic? Some side effects on database and user interface...

FoxTeach 2001

Validation and action

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

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

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

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

Performance Problems

Advantages in maintenance against reaching performance expectations

FoxTeach 2001

Stateless and small

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

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

Generic “Treeviews“

  • Complex hierarchical data does not allow for in-between-layers on any “available“ hardware

FoxTeach 2001

Conceptual problems

Conceptual Problems

Each tier has its own unanswered logical questions

FoxTeach 2001

Somehow redundant rules

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

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

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

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

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

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

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

Basic three tier application building

Additional Material

Where to go from here ? Where to find additional information ?

FoxTeach 2001

Companion cd

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

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

FoxTeach Web Update Page

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

Thank you!

Please remember to fill out your evaluation.

FoxTeach 2001

  • Login