1 / 48

Basic Three-tier-application-building

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

mrinal
Télécharger la présentation

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Basic Three-tier-application-building Session V18 Rainer Becker dFPUG, Germany FoxTeach 2001

  2. 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 • But I am not bilingual ! FoxTeach 2001

  3. Who are you? Visual FoxPro Programmers trying to match the capabilities of the tool against a confusing number real world request FoxTeach 2001

  4. Remember Windows DNA99? lokal tables COM-Server Client/Server XML-transfer HTML Active Doc COM-Client Windows FoxTeach 2001

  5. Basic Theory The minimum of theory (you might know already) FoxTeach 2001

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

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

  8. VFP-interface with databinding Advantage: Faster to develop, more performance Disadvantage: Business tier can be bypassedData navigation problems Example for strict structure FoxTeach 2001

  9. Words and Tiers • Typical Tiers • User Interface • Business Logic • Database Important Words • Request • Notification • Cache FoxTeach 2001

  10. Replace Front-End • No direct application access or • „Web Glue“ (=redundancy!) FoxTeach 2001

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

  12. Replace Front- and Back-End FoxTeach 2001

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

  14. Basic Implementation Coding the first set of classes FoxTeach 2001

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

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

  17. Basic GUI Layer Beware – it‘s a VFP-GUI ! FoxTeach 2001

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

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

  20. GUI Button Functionality • cBO, cBOMethod, lEnableWhenChanged • Click • GetBORef( .cBO ).&cBOMethod • Refresh: If ! Isnull() = TripleLogic • GetBORef( .cBO ).IsChanged() = .lEnableWhenChanged FoxTeach 2001

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

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

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

  24. Business and Data Objects First view on similarities between these layers and small implementation to start with FoxTeach 2001

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

  26. Data Access Layer • Tablemove • add, delete, first, last, next, prev • Tablework • save, restore • Serviceclass for Open • Table, alias, order, readonly, buffering FoxTeach 2001

  27. Business Logic How and where to place the logic? Some side effects on database and user interface... FoxTeach 2001

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

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

  30. Status Information • Invalid records should be saved persistently • Valid status of record depends on its role • Even more so in logical tables FoxTeach 2001

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

  32. Performance Problems Advantages in maintenance against reaching performance expectations FoxTeach 2001

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

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

  35. Generic “Treeviews“ • Complex hierarchical data does not allow for in-between-layers on any “available“ hardware FoxTeach 2001

  36. Conceptual Problems Each tier has its own unanswered logical questions FoxTeach 2001

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

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

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

  40. How to prepare for Multi-Tier? If standards and designs change, how can I prepare my architecture in a somehow stable way? FoxTeach 2001

  41. User interface depends on environment • Interactive Interfaces • Windows Styleguide • Instantiated COM-Server • Disconnected environment • Processing FOXISAPI-hit • Processing XML in WebService FoxTeach 2001

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

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

  44. Additional Material Where to go from here ? Where to find additional information ? FoxTeach 2001

  45. Companion CD • Bo_base.vcx • Gui_base.vcx • Gui_button.vcx • Reise.vcx (application example) • Reise.dbc • Reise.scx • Reise_main.vcx FoxTeach 2001

  46. Visit other Sessions • V12 “Developing N-Tier Applications with VFP” • Jim Booth • V14 “Building World-Class Visual FoxPro COM Servers“ • Kevin McNeish FoxTeach 2001

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

  48. Thank you! Please remember to fill out your evaluation. FoxTeach 2001

More Related