Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy two methods from one class to another
Message
De
08/06/2010 12:53:19
 
 
À
08/06/2010 12:30:03
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01467735
Message ID:
01467958
Vues:
87
Mike --

There is no need to open PEM Editor twice.

There is a feature (available from the context menu on the combobox) which allows you to copy all the PEMs for the current object into PEM Editor's internal clipboard. You would do this on one of the classes.

Then you would go to the other class (since it seems, from your message, that these are not related classes, you'd have both of them open).

You would then go the the context menu again and select "compare with copied object". This will show you a form comparing all PEMs between the two objects, identifying differences between them -- those PEMs found in both, with different values or code, as well as those found in one class but not the other.

There is a related feature, "Compare with parent class", which identifies which PEMs in the class being edited match the values in their parent class. This can be very handy in re-factoring. Furthermore, that form allows you to reset to default any values that match their parents as well.



>Hey Jim
>
>I heard the interview with Andrew. Congrats! One thing I want is an ability to compare two classes' PEMs. I occasionally inherit applications where there are copies of vcx files with minor changes. Can your tool be launched twice - once per class?
>
>>Thomas:
>>
>>(1) The features in PEM Editor for copying properties/methods from one object to another were a direct result of discussions about tools that could be used to facilitate re-factoring.
>>
>>(2) "use them only to move method to a common parent. In this case this seems to be impossible, which can happen in single-inheritance languages like vfp." ... not quite true. Yes, it is true that you cannot have a class and its parent open at the same time, but PEM Editor allows you to copy all PEMs to a virtual clipboard at once -- meaning that you can then close the child class, open the parent class, and then selectively paste PEMs into the parent class.
>>
>>>Naomi,
>>>>I have two separate form classes. I added two custom methods to one form class. I found that I need these methods (with descriptions) in another form's class as well.
>>>
>>>>How can I copy these two methods form one form to another?
>>>
>>>while the PEM-Editor capabilities are really great, use them only to move method to a common parent.
>>>In this case this seems to be impossible, which can happen in single-inheritance languages like vfp.
>>>
>>>Copying is IMHO ***the*** most telling mark of a programmer either unwilling or too overworked to think straight.
>>>
>>>Granted that you may encounter a bad situation in existing object hierarchies,
>>>but with a few extra strokes you can factor the method out into a special object
>>>you can add to each form - for form methods the best approach, as any "this" references in the org method
>>>can be changed to "thisform" while testing a s a form method and will work identically on a sub-object.
>>>
>>>For methods living originally on other objects you can use a "dirtycall"-object on your app object,
>>>to which you move the method code and prefix the parameter list with toThis and toThisForm -
>>>within 5 minutes you have a better (while certainly not perfect) solution.
>>>
>>>DRY code is the target of the lazy programmer proud of his virtue!
>>>As you usually opt for better code, don't even think to ask for help in accomplising a *real* copy ;-)
>>>
>>>regards
>>>
>>>thomas
Jim Nelson
Newbury Park, CA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform