Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Class vs Prg
Message
 
 
To
11/04/2002 12:28:10
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
00639155
Message ID:
00644586
Views:
27
Daniel,

How many places the code needs to be changed depends on what techniques were used to develop the code in the first place.

If a UDF is copied into different files for several clients and some of them have customizations then all those files need to be changed.

If the UDF is in a library and the code is implemented as one huge CASE statement controlling it's variable behavior then it only needs to be changed in one place. The major problem with this is that the module becomes more and more fragile and error prone as time goes on.

It's even possible to have a poor O-O implementation that would necessitate changing code in several places.

I am a strong advocate of eliminating duplicated code as much as absolutely possible. Sometimes O-O is the best way to achieve this, other times a simple UDF is the best way.

>> Now think in terms of reuse. Client A wants the MessageBox to timeout,
>> Client B wants it to whistle Dixie on critical alerts. Client C wants
>> something else to happen. What do you do? Do you replicate the .prg in
>> each client's project folder and customize the code for each client? 6
>> months from now Client A finds out that you have a whistling MessageBox
>> and they would like that to only they want it to play Stars and Stripes.
>> You know have to open both versions of the code and copy/paste relevant
>> code from one to the other, and you might have to change all of the calls
>> to your function thoroughout the app. Or have you built all of this
>> functionality into one MessageBox.prg that has several CASE statements and
>> 100 lines of code? What happens a year from now when you find an obscure
>> bug in the code that is now replicated across 10 clients? You have to make
>> the exact same code fix in 10 places.
>
>Although I agree with you that the message box should be coded as class with possibly subclasses added to the mix, I believe you are wrong when you state that the code has to fixed in 10 places. If the code is in library and the library is referenced by each project, the code has to be fixed in one place only.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform