Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclass class in PRG file
Message
From
22/06/2018 17:50:36
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01660806
Message ID:
01660839
Views:
42
>>Which is better? Yes and no. It's sometimes good that you can't reference upstairs, or you can get into a habit of writing fugly code like xx=this.parent.parent.parent.pgf.page4.cnt2.DoSomething(), which I've seen a lot in visual classes. That can break in a dozen interesting ways. OTOH, it's quite common to have in cmdSomething.click() a call to ThisForm.DoTheThing() - which is actually recommended. That actually breaks encapsulation in a way, but in a very limited way - yes, you can have direct calls from a member to a form-level method. But if you see .parent.parent somewhere, it's perhaps time to rethink the design.
>>
>>It's more or less a step in the pursuit of an answer to the prime question of OOP - where does the code go?
>
>Thank you for the explanation. I do have parent.parent in my program in many places (of probably million lines :). I am not sure I have time to redesign since I plan to retire in 10 years :).

As long as you don't need to do anything seriously different with such code - add a couple of new features which may require some reorganization, for instance - then just don't touch it. The rust holds the ship.

But if you must, then refactor that one form/class.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform