$bobjs and subclassing

Michael Monschau michael at brainydata.com
Sun May 13 08:32:27 EDT 2012


Hi Will,

All objects by default are private to their class. You cannot access them from a subclass using $cinst, as that addresses the instance of the subclass only.

It is the superclass that must provide access to its objects. A good option for making objects in a superclass accessible is by creating item reference variables in the super class with the notation to the object as its initial value. As long as the subclass does not have an identical named instance variable you will be able to access it.

This has two benefits
1. The subclass does not need to know anything about the structure of the superclass, all it needs to know there is an item reference called "refLabelA". Less code to update when something changes.

2. The initial value calculation will only execute ones, so there is a performance benefit when the object is referred to more than once. It is much faster to access an object via an instance variable item reference than having multiple hard coded notation paths in your code.


Regards,
Michael

Michael Monschau (Director)
Brainy Data Limited

Reply To: michael at brainydata.com
Phone: +44 (0)870 474 0708
Web: www.brainydata.com the home of Omnis Components and Developer Services




On 11 May 2012, at 22:28, Will Adkin wrote:

> Michael/Mark,
> 
> Thanks for the ideas, I think a $setLabelText method is definitely the way to go… 
> 
> The only problem is that the method will have to be added independently to all of our 250+ windows - we can't add it to a single window superclass. What I'm thinking is some kind of pre-deployment method which can add/replace the $setLabelText method in all window classes - just to keep things nice and automated from a single code source…
> 
> That's a much better solution for us - thanks guys!
> 
> Will Adkin, Software Development Manager, Lineal Software Solutions Ltd
> Apple Reseller, Microsoft Partner, SQLWorks Business Partner
> office phone: 01271 850550 | web: lineal.co.uk | email: will at lineal.co.uk
> 
> 
> 
> 
> On 11 May 2012, at 19:07, Mark Phillips wrote:
> 
>> 
>> On May 11, 2012, at 10:48 AM, Will Adkin wrote:
>> 
>>> I have come to the conclusion that it can't be done. The individual $bobjs are only accessible by code that exists at the same level in the superclass structure...
>> 
>> Will,
>> 
>> I think Michael is on to it. If you add a class method the to the sub window class, you might be able to kick off the text assignment. I add a public method called $init, then run that when I need to "reset" the class. Sometimes I invoke it from the constructor, but frequently I just call it from the outer window.
>> 
>> A key thing to remember is to avoid notation that reaches into an instance and modifies it. Better to use a public method defined in the class, and invoke that from the "outside".
>> 
>> hth,
>> 
>> - Mark Phillips_____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> 




More information about the omnisdev-en mailing list