Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ReturnThis()
Message
 
 
À
01/06/2013 10:23:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01575398
Message ID:
01575401
Vues:
62
>>I am using a strategy with Bindevent() to return an object reference go a business object.
>>It works so great and is so helpful in many different situations, so I published this in the
>>article below.
>>
>>http://cisberner.wordpress.com/2013/06/01/returnthis-visual-foxpro/
>
>
>I don't understand how what you've done by using BindEvent() and ReturnThis() achieves anything different than the abilities exposed by calling a custom added method to do the same. Or to reference the object itself using its parentage call. Or to create a generic object interface called "theObject" through which you can directly reference the object that is given by ReturnThis().
>
>What am I missing? What is ReturnThis() doing that other methods won't do?

I think it is harder to understand when you haven't really applied it in practice.
To give you a simple example:
Previously I created a container object, dropped it on a form, and on the button click I would say:
MessageBox(THISFORM.EmployeesBiz.FullName)
Which did work, but there are several problems:
- THISFORM does not exist during the design, so you won't get intellisense.
- You don't know that there will be at run time an object on the form with the name "EmployeesBiz". You know it because you depend on it, but that's the problem, you depend on a specific situation, and when that situation changes, you have to modify your class.
- You could create another method on the form, and forward the method call to the form: THISFORM.DoShowEmployee(). But that means the container looses its functionality, forwards it to the form, and thus will not be reusable anymore. Further, you don't know if the form has this method, it won't show up in intellisense and you cannot drop the container on another form that has a different implementation, or you copy the entire code. Which we have done in the past, regrettably.
- You can't change the reference easily during runtime.
- You can't move this strategy to strongly typed languages because there you cannot evaluate the expression during design time.

I have for instance forms where I have a collection of several business objects. Different containers (similar as life tiles in Windows 8) reference different business objects. I used to have lots of code to handle these situations, causing bugs and errors in the code. I also had container objects that I could not release because of object references. Now I can drop the same container on another form, and still use the functionality without changing any code.
Christian Isberner
Software Consultant
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform