mercredi 23 août 2017

Comparison of Javascript Pattern/Paradigms / Best practice of design

I am compiling a list of biases(both proponents and antiponents) to explain to my team lead why our current javascript design is outdated. This is an open-ended question, I am looking for 3rd party analysis on the pro's and con's of the following to paradigms.

Our existing paradigm on the system looks like the following

var class= (function () {

var property1 = 8;

var method2 = function (value) {
    var instance = this;
    return value;
};

var method1 = function () {
    var instance = this;
    return "Hello";

};

return {
    init: function () {
        alert(methodTwo(methodName()));
        method2();
        console.log(state);
    },
    method1: function(){
        method1();
    }
}

})();

I want to convince him of the following as a best practice

namespace.MyClass = function(){
 var instance = this;
 instance.Property1 = 8;
 instance.Method1 = function(){};
 instance.Method2 = function(){};
}
var myobject = new namespace.MyClass();

Aucun commentaire:

Enregistrer un commentaire