>>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.