So I'm starting to learn java... No no, it's ok don't panic. I'm being safe.
Seriously though I've been reading up on a few articles concerning best practices. I would rather not develop bad habits that I will have to break later. I came across an article concerning using the constructor method or literal when creating an object.
the example they gave is below. To my understanding changing the elements of o from o.name etc. to this.name helps keep maintenance down should you have to edit/rename and so on. As is this was the first exposure to creating objects it is the default method I turn to as I'm learning. My other concern is which method is preferred in minecraft? Despite certain approaches to code in the end most people concern themselves (as I've heard) with the overall game impact in terms of system resources and the impact it has on the user. With that in mind... which isbetter preferred or most practiced in the community?
Also if there's any other advice the community would like to give. I'm not modding at the moment. I'm still working through fully understanding java as a language before I try to move into that realm.
Bad method
var o = new Object();
o.name = 'Jeffrey';
o.lastName = 'Way';
o.someFunction = function() {
console.log(this.name);
}
Better
var o = {
name: 'Jeffrey',
lastName = 'Way',
someFunction : function() {
console.log(this.name);
}
};
Seriously though I've been reading up on a few articles concerning best practices. I would rather not develop bad habits that I will have to break later. I came across an article concerning using the constructor method or literal when creating an object.
the example they gave is below. To my understanding changing the elements of o from o.name etc. to this.name helps keep maintenance down should you have to edit/rename and so on. As is this was the first exposure to creating objects it is the default method I turn to as I'm learning. My other concern is which method is preferred in minecraft? Despite certain approaches to code in the end most people concern themselves (as I've heard) with the overall game impact in terms of system resources and the impact it has on the user. With that in mind... which is
Also if there's any other advice the community would like to give. I'm not modding at the moment. I'm still working through fully understanding java as a language before I try to move into that realm.
Bad method
var o = new Object();
o.name = 'Jeffrey';
o.lastName = 'Way';
o.someFunction = function() {
console.log(this.name);
}
Better
var o = {
name: 'Jeffrey',
lastName = 'Way',
someFunction : function() {
console.log(this.name);
}
};