PDA

View Full Version : Clean Code...



zquirm
6 Nov 2006, 11:06 AM
I love your way of organizing code and you seem to have a system in terms of creating it. I was wondering if you might make a post about creating clean code.

for instance, why you would say:

Example = new function() {
return { }
}

rather than:

Example = {
this.something = a;
}
var test = Example;

I know the above are different. I'd just like to know in what case you use certain types of code structure.

does that make sense?

jack.slocum
6 Nov 2006, 4:34 PM
There's a new sticky with some great links on this.

Basically the idea is to create different scopes so you can have private and public variables.


Example = new function() {
// private stuff goes here. Can be accessed without using "this"
// by functions inside the Example block
return {
// public functions accessible outside of Example
}
}

zquirm
6 Nov 2006, 5:51 PM
what do you mean "new sticky"...sorry

jack.slocum
6 Nov 2006, 6:53 PM
Post "stuck" to the top of the list in the forum. ;)