I am declaring a "class" using a "constructor method". In both samples, properties uuid
and dateCreated
are initialized but in different places.
I would like to know the "best practice" in this scenario and why (also in terms of readability).
Solution A
define([
'dojo/_base/declare',
'dojo/_base/lang',
], function (declare, lang) {
return declare('xxx.xxx.Command', null, {
uuid: utilis.UUID(), // IS GOOD PRACTICE?
dateCreated: Date.now(), // IS GOOD PRACTICE?
action: null,
properties: null
},
constructor: function (action, receiver, properties) {
this.action = action;
this.receiver = String(receiver);
this.properties = properties;
}
});
});
Solution B
define([
'dojo/_base/declare',
'dojo/_base/lang',
], function (declare, lang) {
return declare('xxx.xxx.Command', null, {
uuid: null,
dateCreated: null,
action: null,
properties: null
},
constructor: function (action, receiver, properties) {
this.uuid = utilis.UUID();
this.dateCreated = Date.now();
this.action = action;
this.receiver = String(receiver);
this.properties = properties;
}
});
});