Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Seriously, who believes in n-tier development?
Message
 
À
14/04/2003 05:50:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00775920
Message ID:
00777174
Vues:
26
>
>The main problem we will face is the fact that the Programmers will have to learn 3-tier design as well, and I think this will at LEAST double the work.
>

It depends (if you are going to be using a new framework, then I'd agree). If not, I would at least make an effort to isolate code. Some simple rules that most developers can follow:

1. Controls on forms delegate to form-level methods.
1a. Have a New, and Save button? Call the New() or Save() method on the form.
2. Form methods delegate to a business object for all business logic, queries, etc. Forms are only responsible for UI issues.
2a. New() and Save() would call a business object to do this. The result of the New() and/or Save() is returned back so they form can respond accordingly.
3. Business objects don't display UI/messages. They leave that to the form. Messages are passed as parameters, return values, and properties.
3a. See 2a.

The business object layer can actually be made up of a data layer in addition to a business layer. A simple way of isolating data from the business object would be to encapsulate common data actions:

eg.

1. MoveNext()
2. MovePrevious()
2. Find()
3. Query()
4. Requery()
5. Save()
6. New()
7. Delete()

Your business object calls this data layer instead of coding this inside the business object methods. For example, for SQL querys, pass the SQL code to Query() (or pass it the name of a view/table; follow a simple naming convention here). For Find(), pass in the PK and let the data layer code do a SELECT on the PK. All of that code is pretty easy to abstract.

This won't protect you in all cases, and you're bound to still end up with places where code isn't in the correct layer. However, it will make things vastly easier to move around and reuse. Forget physical n-tier stuff, I've found the most useful part of this stuff to be the fact that it's EASY to reuse code in multiple forms, w/o duplicating code.

All you're asking a developer to do is spend another 2 or 3 seconds deciding where the code belongs. They won't always make the correct decision, but it's still better than nothing.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform