Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BINDEVENT() (and related) - best placement of code?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00781200
Message ID:
00781475
Vues:
24
>>>Is there some optimal place(s) to put the code to make their existence/usage evident to future code readers?
>>
>>No. BindEvent() can be used at every single level of the application.
>
>I know that Mike. The concern is that a BINDEVENT() is like setting a time bomb at execution time. Unless the programmer is well aware that BINDEVENT()s are active s/he will likely observe 'unexplainable' processing paths being executed. I can see benefit to adopting some standardized place to put these lines simply for future reading of the code for debugging/enhancement purposes.
>BINDEVENT() has the potential, as I see it, to make spaghetti code look good by comparison. At least with spaghetti code one can follow it to learn exactly what it does. With BINDEVENT() things can suddenly happen with NO INDICATION in the code path at all. I'm looking to minimize this if its sensible.
>
>>
>>>My answer to when it should be useful is: in the general case, outside of classes, with perhaps some empty methods coded within classes to facilitate usage of BINDEVENT() externally.
>>
>>By outside of classes do you mean in a procedural PRG? In this context, every line of application code should be in a class.
>
>Sorry, no, I mean outside VCXs or actual class code. In other words, I mean that BINDEVENT() should only be coded in method/event code of instantiated objects.
>
>>
>>>And I don't think that RAISEEVENT() has any place within class code at all. Does this make sense or is it cutting off valuable potential uses?
>>
>>I'm working under the assumption that 99% of the RaiseEvent()s you'll write will use THIS as the first parameter. Based on that, you would only use RaiseEvent() in class code.
>
>I guess I misused the term "class code" (see above). What would I call code that is NOT "built in" to a class (VCX or prg-based) but is for the instantiated object within the application itself?


I thought about this for awhile, as I have been playing with this myself.
If the BindEvent(s) can be placed in a "SetBinds" method of the code, that can be called in the Init of the container object, this would give the programmer a heads up. It will also encapsulate the code in a class making it more reusable.
Tracy
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform