3 ms·
I completely agree, except for the private methods portion. I personally find (function(){ //implementation methods and variables return{
by ep103 13y ago
I completely agree, except for the private methods portion. I personally find
(function(){
//implementation methods and variables
return{
//public methods
};
})()
to be far easier to read than
var myObject = {
//A random mix of public and implementation details
};
Though I will admit that my main reason for believing the above, is that when you work with developers who do not spent much time in JS, and they realize they have to write something complicated without private methods, they tend to write either monstrously long public methods as a result, or write as normal and litter the interface of the object, thereby completely breaking SOLID. The first method above avoids that problem.