What elements constitute good programming form? I eternally hear of "elegant" code, but never any elaboration on what makes code elegant. I'm not a great programmer, and I will brute force if/when/always necessary; so I am greatly keen on learning about this subject.
Great code is like great porn - you know it when you see it.
Name:
Anonymous2007-11-09 18:27
Abstraction in the right places, sticking to standard styles, commenting appropriately, making your code readable to yourself in a year's time. That sort of thing.
Name:
Anonymous2007-11-09 18:38
Use a lot of gotos, that's all I can say.
Name:
Anonymous2007-11-09 18:45
if youre bad at programming and dont care to get better, at least make sure your code is legible so people suffer less when reading your garbage.
if youre good at programming, at least use comments to explain abstract portions so others can figure it out what parts are important.
if youre great at programming, you give specs and expect other people to understand your obscure code or do it themselves.
Use comments to explain why rather than how. You should be able to trace how the program works in a debugger.
Name:
Anonymous2007-11-09 19:52
>>8
yes, that seems like a good advice. I rarely comment out what a function/method does, the code should be enough documentation.
Name:
Anonymous2007-11-09 20:26
also, read sicp.
no trolling. reading that book will make your code elegant, believe me.
Name:
Anonymous2007-11-10 2:37
Code is elegant when the calculation is hidden so that one can operate entirely on the program's flow -- the algorithm.
Name:
Anonymous2007-11-10 3:58
Use comments to explain how and why. Code should be as terse as possible, to save space on the filesystem. One-liners should be preferred whereever possible. Study LISP, it will make you a better programmer. Oh, be an active member of the /prog/ text boards is also important.