Page 1 of 2
Static methods - please!
Posted: Wed Sep 17, 2014 11:38 am
by allistar
The subject says it all. Static methods is a core part of most popular OO languages. What is needed is a new method modifier like this:
someMethod():String static;
Then this can be invoked like this:
value := SomeClass.someMethod();
or on an instance:
value := instanceOfSomeClass.someMethod();
We can already do something similar with class constants. The method would need to prevent access to member properties on the class (similar to how conditions limit what can be accessed), but we should be able to access global variables like app.
Workarounds for the lack of static methods tend to be nasty. Creating transient instances of the class is one approach, but that doesn't work if the class is abstract and it's not very efficient.
What will it take for this staple OO feature to make it's way into the JADE language? Come on guys!
Re: Static methods - please!
Posted: Thu Sep 18, 2014 5:27 pm
by suzuki1100
+100
Fully agree and I dislike having to create a transient object to access a method that should be a static method.
Gets even more revolting when performance is an issue and you end up having to store collections of transients to provide static methods.
Re: Static methods - please!
Posted: Fri Sep 19, 2014 3:56 am
by Stokes
Yes please - creating transients to access a method is messy
Re: Static methods - please!
Posted: Thu Oct 02, 2014 5:23 pm
by suzuki1100
We have 3 Jade developers interested in Static methods surely there are others !!!
Please post your support for this feature
Re: Static methods - please!
Posted: Thu Oct 02, 2014 10:02 pm
by BeeJay
Interestingly I've never really felt hamstrung by the lack of static methods in Jade. Maybe it's because of the type of systems I've worked on, or the nature of the underlying architecture of those systems, that has meant that I'm never really crying out for static methods very often?!?
I find the same thing happens when people start talking about the lack of method overloading, or the lack of parameterised constructors, being a major issue for them when working in Jade. Again, perhaps it's just that I've been working without them in Jade for so long that I don't miss them, or it's to do with the underlying architecture of the systems I've worked on being designed with those 'limitations' in mind that they never show up regularly as being an issue for me?
You can still put me down as another +1 for having static methods, I probably won't end up using them very often but on the odd occasion I do I'll enjoy having them available and who knows, once they are available maybe I'll start to see more opportunities to use them.
Cheers,
BeeJay.
Re: Static methods - please!
Posted: Fri Oct 03, 2014 1:45 am
by ghosttie
I'd like static methods, I just don't think we'll get them.
Re: Static methods - please!
Posted: Fri Oct 03, 2014 11:49 pm
by Dr Danyo
Im inclined to agree with BeeJay regarding static methods, nice to have and if it was there I would use it.
However top of my wish list is parameterised constructors, I would be using those consistently if they existed. Being able to create an object and initialize it in a single step (subsequently making it immutable if all properties were protected) would be a great benefit in my mind. Still doable without parameterised constructors, but I always end up writing much more boiler plate then I would like.
- Dr Danyo.
Re: Static methods - please!
Posted: Sat Oct 04, 2014 1:14 am
by ghosttie
However top of my wish list is parameterised constructors, I would be using those consistently if they existed. Being able to create an object and initialize it in a single step (subsequently making it immutable if all properties were protected) would be a great benefit in my mind. Still doable without parameterised constructors, but I always end up writing much more boiler plate then I would like.
+1
Re: Static methods - please!
Posted: Sat Oct 04, 2014 7:10 pm
by suzuki1100
Agreed +1
After static methods as technically they should be easy for Jade to implement
Re: Static methods - please!
Posted: Mon Oct 13, 2014 12:59 pm
by davidmellow
Definitely a vote here for static methods, and I miss both method overloading and parameterised constructors also.
Interesting reading the variety of opinions regarding each, but for me the lack of method overloading is perhaps what frustrates the most.
Cheers.