Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best Pratice: Require passed parameters?
Message
From
18/12/2002 04:12:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
17/12/2002 15:58:18
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00733856
Message ID:
00733998
Views:
16
>I was happily building business objects, and suddenly I noticed I was doing method calls to the objects two different ways. All the objects work off parameterized views of the data; some methods operated on "pre-existing data", while others passed the parameter and fetched a new data set.
>
>Because this is a recipe for programmer frustration, some of the methods are going to change, but which ones..? Which methodology is better, and why?
>
>Or would it be better to recode them all so that no parameter worked on the current data, and a passed parameter requeried before acting?
>
>Chris.

Chris,
It'd depend.
In most cases I tend to use last option where applicable. ie: Think of VFP functions. Most of them work on 'current' if no parameters are specified :

use Table1 in 0
use Table2 in 0
*..
select Table1
? tag()
? tag(1) && Override
? tag(1,'Table2')

OTOH there are functions that need at least one or more parameters be specified :

? seek(NonOptionalParameter)

And where applicable I tend not to display any parameter error in the function/procedure/method itself but inform the caller routine (mostly thinking my routine could be used as a COM dll where no UI allowed or it should be caller routine's responsibility to provide UI - ie: I'd like to have something like use('myTable','exclusive') over 'use myTable exclusive'). Good try..catch is coming :)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform