Other Software > Developer's Corner
Beautiful Code: In your opinion, what makes code Beautiful?
f0dder:
3. If it uses more memory, so what? Premature optimization is the root of all evil. Lets not optimize that until a problem is created by being too organized, which is near impossible. - CodeByter
-Codebyte (February 18, 2009, 10:38 PM)
--- End quote ---
Premature pessimization can be just as bad, though - a mix of sloppy design and sloppy code can sometimes lead to requiring more a less a rewrite to fix performance problems later on. Don't obsess with needles micro-optimizations, but be careful about using "premature optimization is the root of all evil" as a lazy blanket statement excuse for writing crap code as well :)
Eóin:
I don't know, but outside the extremes like perl one-liners and c++ overloaded operator gobbledygook I find less code enormously easier to read.
For example I'd extremely limit introducing an intermediate variable when the return of a function is needed only once and can be written inline. This has nothing to do with efficiency, a compiler would probably make the same code anyway. But yet another variable, even clearly named, just complicates the code.
Off hand now other examples are hard to think of, but ultimately I would say that I virtually never come across case where 2 lines is actually less legible than 20. Use good names but otherwise be a succinct as possible I'd say is the best rule of thumb.
KenR:
Maybe I missed it somewhere, but I also think that formatting adds a lot. You can tell a lot about where you are in a program from indentation and other stylistic matters that the compiler doesn't care about, but makes the programmers life a bit simpler. Simple-minded I know, but so am I. :P
Ken
Crush:
I find it beautiful to create such complicate code (for maximum optimising) that I need after some time hours to understand what I did there how and why. But hey, I´m not a pervert, I only follow my animal instincts!
The strange reason could be hidden deep in the social role behaviour of men: The mystery of unknown secrets makes also women more attractive and it´s a lot of fun to reveal them. After a while out of sight they regain this cloak of mystery again.
Target:
I'm no coder, but I always try and stick to this simple rule - always code for the lowest common denominator (usually me...)
This applies equally to the use (how many of us have found a piece of software that could be the answer to all our prayers, if only we could just work out how to use it...) AND maintenance of your code (most of the posts above have commented about having to spend considerable time relearning code in order to make a change)
Brevity is always good, but if the benefits are negligible it's always better to write simple and clear code
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version