Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Tell me your style

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.

Name: Anonymous 2010-02-22 11:44

Your code must be a chore to debug.

Name: Anonymous 2010-02-22 12:07

Hello, FrozenVoid.

Name: Anonymous 2010-02-22 12:17

When I program something I follow these principles:

1. do not abstract reusable code into functions unless I already need to use it in two or more places. Also, if the repeating pieces of code in question are five or less lines and physically near, then having two or even more almost identical copies is OK.

This does not apply to creating separate functions to separate responsibilities (as opposed to abstraction/reuse).

Otherwise I will more often than not find that my idea of how the program should look like and exactly what functionality I'm going to reuse has changed several times before I actually reused it (sometimes even disappearing entirely) and I spent a lot of effort maintaining the abstraction, and it might have even prevented me from finding more efficient ways of partitioning the code.

As for the smallish pieces of code, I've found that cognitive load of recognizing the repeating pattern and the deviations from it in the copypasted code that fits on one page can be pretty insignificant compared to what is required to remember what a function defined elsewhere does and imagine the results that different combinations of parameters produce. The former is performed mostly by visual cortex, no higher cognitive activity required, unlike with the latter.

2. Again, I write code in a way that makes it relatively easy to refactor it into something reusable or something that fits into the larger structure, rather than trying to make it reusable or having a well-defined interface from the start. When the need really arises I'd have incomparably better idea, what that need is, until then I'd better follow Sun Tzu: "The ultimate skill is to take up a position where you are formless."

Name: Anonymous 2010-02-22 12:36

1.Small functions cause huge overhead on nesting.
2.Recursion and objects are often the best/elegant solution.
3.Is FV trolling functional programming?

Name: Anonymous 2010-02-22 13:42

When I program something I follow these principles:
1) Solve the problem
2) Once I've solved the problem, look for missed generality, and solve a more general problem
3) Refactor for readability
4) Macro refactor for compile-time constant constraints
5) Goto (2).

To solve a problem, use recursion, even if expressed iteratively.

Name: !!bs+RJAOyXTwZJRG 2010-02-26 5:15

test

Name: Anonymous 2011-02-03 7:35

Don't change these.
Name: Email:
Entire Thread Thread List