I adhere to the PEAR conventions.
As far as i'm concerned, all code should be readable from beginning to end.. i tend to space out every new section/loop further to make it standout more.
Also i like to leave a lot of comments in the source to explain what each section should be doing or what choices lead to what section, including which variables to set beforehand to let it funktion proper. This has saved me several times from fatal errors.
I just use the way in which I think looks the most elegant. Not too much white space, but enough to make it look nice.
Edit: I remember a long time ago I used to code in one line only.very messy
i make my JS very un-readable to confuse my friends who cheat my home work![]()
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
www.amrosama.com | the unholy methods of javascriptCode:eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
I'm sceptical about comments. I always ask if I am about to write a comment can I instead change the code to make it clearer.
For my purposes I want comments to be something a person reads. When you see a comment in my code you know it isn't just there for reference. You'd better **** read it or otherwise you will be feeling pain at some point. I tend to explain strange implementation decisions and why they actually make sense and you should not do the 'obvious' thing.
For example I had one person rewrite my SSE assembly code to 'make it clearer'. I had for some bizarre reason intermixed several distinct sections of code to make it near unreadable. Of course there was a perfectly good comment explaining that modern CPUs take many cycles to load from memory to a register but can perform calculations on other registers while this is loading. So in my matrix/vector multiplication code I was loading the next column of the matrix in before multiplying the current column. That way by the time the nth multiplication was done the n+1 column was already loaded. Doing it the obvious way made the code take 4 times as long.
I find things that state why something is done are more important that telling me what you are doing. After all I know what you are doing, the code tells me as much.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks