Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Business Objects - calling code in Procedure files?
Message
 
À
13/08/2009 13:53:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01417961
Message ID:
01417995
Vues:
60
>I have created some Business Object classes, and now I am creating methods on them that can be called.
>
>For instance, I have a Job business object, that will have a method called .GetItems(tcAlias) which will fetch the child records and place them in the passed in alias/cursor name.
>
>Now, I already have an old procedure that I've had for years in a procedure file that accepts a JobNo and an Alias and it does the same thing that I am wanting the Job object to do.
>
>So, I am wondering if it is a bad practice to let the call to Job.GetItems(tcAlias) just make a call to the existing procedure to get the work done? That way I have the best of both worlds where I can call the procedure in some places where I do not go the BO route, but I can also call the BO method when I am going that way.
>
>So, Job.GetItems(tcAlias) would just make call like GetJobItems(this.JobKey, tcAlias), and that's all he would do. Otherwise, I would copy-paste the code from the procedure into the BO method, and then I would have the code in 2 places! Or I could refactor my app to remove the procedure and force myself to use BO's everywhere, but that is a good chore.
>
>So it boils down to deciding if it's OK for the BO to rely on a procedure file to get his work done, or if he should be fully independent and have all his on code in his methods?

I like making my BO's independent and not delegate too much out to external functions/procedures to do the real work (since it's supposed to be the "go to" object for all things related to "Jobs" in your case). I have a method in my base business objects called GetCursorByKey(tcCursor, tcSourceTable, tuKey, tcKeyField). It basically dynamically builds a query for me, and I can add more specific methods in my subclasses. For example, GetJobItems() would get added to Job and it would basically do this:
LPARAMETERS tuKey, tcCursor

RETURN This.GetCursorByKey(tcCursor, This.cTable, tuKey, "NameOfField")
So in your case I'd probably duplicate the code in my BO that you've currently got in the procedure, then slowly change the references to use the BO to retrieve this information instead of calling the procedure directly.
-Paul

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

Click here to load this message in the networking platform