Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
gabordemooij
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
18 ms
·
181.
▲
by
gabordemooij
15y ago
It all boils down to maintainability. In my experience the minimalist approach solves much of the complexity of JS by eliminating some features that are not required (performance might be an issue but never had any problems with it in pract
182.
▲
by
gabordemooij
15y ago
Object.create does not even work in most browsers! So you cannot even use the preferred solution in todays most popular browsers: http://www.w3counter.com/globalstats.php?year=2011&month... http://kangax.github.com/es5-compat-table/
183.
▲
by
gabordemooij
15y ago
Uhm, no... http://php.net/manual/en/language.oop5.patterns.php A singleton uses a static factory method in PHP and Java. AFAIK there is no (mainstream) language where a singleton is an instance method.
184.
▲
by
gabordemooij
15y ago
I think the nested notation is simply more maintainable. MyClass = { staticMethod: function(){ } createNew: function() { obj = {}; obj.instanceMethod = function(){} return obj; } } Also, I f
185.
▲
by
gabordemooij
15y ago
I mean that with the minimalist approach you can define static methods in your 'class' body, thus grouping them neatly together: MyClass = { getInstance: function(){ ... } } vs MyClass = function(){ } //outside function body... MyClass.
186.
▲
by
gabordemooij
15y ago
Okay fine. Then tell me how do you write javascript OOP; what's your favourite way. Can you give me an example of your code? I am willing to admit mistakes but I have to be convinced.
187.
▲
by
gabordemooij
15y ago
No. Just no. Simpler is better, especially if there are no real drawbacks. I think this remark about entry level developers is snobistic. I have an open mind and I am always willing to learn. Yet you just dismiss my approach without providi
188.
▲
by
gabordemooij
15y ago
Yes, it might help you in daily work environments.
189.
▲
by
gabordemooij
15y ago
This is not true. With prototypes you can override default functionality thus introducing unexpected behaviours. While you can indeed override individual instance methods with augmentation, you cannot override the 'general' toString() funct
190.
▲
by
gabordemooij
15y ago
Yes it is, because you can not add them in the function body: cls = function(){} cls.staticMethod = function(){} vs cls = { staticMethod:function(){} } I prefer the latter because the static method can be defined within the body of the
191.
▲
by
gabordemooij
15y ago
No, it isnt. It's cleaner because the class-object is an object instead of a function, this makes it possible to add static methods.
192.
▲
by
gabordemooij
15y ago
No, prototypes are a wrong idea. They are both complex and dangerous. Complex because you have to add methods indirectly and yet there are no classes (I mean, seriously... how can anyone claim this makes sense?). Dangerous because you can e
193.
▲
by
gabordemooij
15y ago
Why do you assume I don't understand prototypical inheritance? To me this highlights part of the problem of our community. Once you choose not to use a certain feature you are being regarded as stupid. What ever happened to the KISS princip
194.
▲
by
gabordemooij
15y ago
* Yes createNew is not very optimal, in practice this is not really an issue though. Furthermore I value maintainability over performance. * They share the same object, so it's not composition. Does it really matter that it is not 'pure' in
195.
▲
by
gabordemooij
15y ago
I dont use new, prototype and this because I find them confusing. While it may be trendy and cool to claim that this is just me being stupid and you being smart I have seen many disasters happen by people who claim to 'fully understand' Jav
196.
▲
by
gabordemooij
15y ago
Javascript can be quite daunting. I have seen many disasters with Javascript applications. This is why I now teach Javascript differently, I have written down a minimalist JS approach. This way of writing Javascript allows you to implement