Name: Anonymous 2010-02-22 11:29
When I program something I follow these principles:
1. Abstract reusable code into functions.
2. Code with intention to expand the codebase.
3. Avoid object trees and function methods(binding functions to objects).
4.Avoid any form of recursion.
The style is a mix of functional and procedural flow.
example:
//Assignment
var a=fill(10);
//A function which builds a small alphanumeric string.
function fill(x){var m=x;var res='';for(var i=0;i<m;i++){res+=rchar()}return res}
//A function which generates a random character
function rchar(){if(rnd(0,10)>0){return chr(rnd(32,90))}else{return ' '}}
//A function which creates characters from their charcodes
function chr(x){return String.fromCharCode(x)}
// A function which returns random integers within its bounds
function rnd(b,l){var d=b+Math.floor(l*Math.random());return d}
Every function is free to be reused and modified anywhere.
1. Abstract reusable code into functions.
2. Code with intention to expand the codebase.
3. Avoid object trees and function methods(binding functions to objects).
4.Avoid any form of recursion.
The style is a mix of functional and procedural flow.
example:
//Assignment
var a=fill(10);
//A function which builds a small alphanumeric string.
function fill(x){var m=x;var res='';for(var i=0;i<m;i++){res+=rchar()}return res}
//A function which generates a random character
function rchar(){if(rnd(0,10)>0){return chr(rnd(32,90))}else{return ' '}}
//A function which creates characters from their charcodes
function chr(x){return String.fromCharCode(x)}
// A function which returns random integers within its bounds
function rnd(b,l){var d=b+Math.floor(l*Math.random());return d}
Every function is free to be reused and modified anywhere.