Re: Using Do Code Method to make static method calls: safe practice?
Andreas,
There are those that would ague that Singleton Patterns are inherently evil as they effectively push the scope of the instance into the global namespace. I don’t believe that to be universally true and there are certainly times when a Singleton is an appropriate solution. For that reason I too would like to see support for a private $construct and while we’re at it, true static methods.
Lawrence
> On Jun 23, 2017, at 7:09 AM, Andrea Zen <a.zen@athesiavr.it> wrote:
>
> Hello Peter,
> if I have an Object class where I need one or more static methods, because they are related to that class, I’d prefer to keep them inside that, along with instance methods, rather then creating another Code class only to store them.
>
> Actually, Omnis lacks two important things in my opinion:
> – static methods (real ones I mean);
> – the possibility to make a $construct private (needed for Singleton design pattern)
>
> Andrea Zen
>
>
>> —–Original Message—–
>> From: omnisdev-en [mailto:omnisdev-en-bounces@lists.omnis-dev.com] On
>> Behalf Of Peter van Rooij
>> Sent: Friday, June 23, 2017 11:48 AM
>> To: OmnisDev List – English <omnisdev-en@lists.omnis-dev.com>
>> Subject: Re: Using Do Code Method to make static method calls: safe
>> practice?
>>
>> Hello Andrea
>>
>> Why would you want to do that?
>> If you use it like this, you cannot use instance vars of the object you are
>> calling, so in effect the object acts as a code class.
>> Why than not use the code class? Just to be saf for the future…
>>
>> Regards
>>
>> Peter
>>
>>
>>> On 23 jun. 2017, at 11:40, Andrea Zen <a.zen@athesiavr.it> wrote:
>>>
>>> Hello, in Omnis Studio there is no possibility to declare a static method, but
>> it is known that using:
>>>
>>> Do code method myClass/myMethod
>>>
>>> we can simulate a static method call, regardless of the type of “myClass”.
>>>
>>> I’d like to know if this is a call that can be used safely.
>>> I mean, is it an “official” feature intentionally implemented by Omnis?
>>> Or is it a workaround that works by chance and could be removed/changed
>> in future versions? Has anyone ever talked with Omnis about this?
>>> After all, “Do code method” is meant to be used with code classes, there’s
>> no mention in the manuals about this particular use with every type of class
>> to call methods as static ones.
>>>
>>> Andrea Zen
>>>
>> __________________________________________________________
>> ___
>>> Manage your list subscriptions at lists.omnis-dev.com
>>
>>
>> __________________________________________________________
>> ___
>> Manage your list subscriptions at lists.omnis-dev.com
> _____________________________________________________________
> Manage your list subscriptions at lists.omnis-dev.com
_____________________________________________________________
Manage your list subscriptions at lists.omnis-dev.com