Linked by Thom Holwerda on Wed 26th Sep 2012 23:25 UTC, submitted by MOS6510
General Development "Having read this, one realization is that better code often means less code. I don't think about lines of code exactly, or something similarly stupid, but in terms of meaningful code. However, argument for less code isn't about making code as compact as possible, avoid redundancy, etc. The argument is about not writing code at all whenever reasonable or possible. Should we focus on deciding what should and what should not built instead of polishing our software development craft then? Yes and no. Yeah, I know. Exactly the kind of answer you expected, isn’t it? Anyway, you can't answer this question meaningfully without a context."
Thread beginning with comment 536607
To read all comments associated with this story, please click here.
better or not
by zhulien on Thu 27th Sep 2012 02:48 UTC
Member since:

Better code is better because it suits it's task better. Sometimes it is smaller, sometimes it is faster, sometimes it is more maintainable, sometimes it is easier to debug, sometimes it is easier to change, sometimes if you are extremely lucky, it is all. All good programmers will realise they will always have ways to improve and inprove the way they do things over time when they have the opportunity. I'm being very broad, because a good program designed to run in 2kb on a Z80 based micro controller is going to have different requirements and constraints likely a good program that is to run on a modern desktop computer.

Reply Score: 5

by Lennie on Thu 27th Sep 2012 09:13 in reply to "better or not"
Lennie Member since:

Programming languages are like other languages if you ask me.

An experienced programmer is probably more eloquent in defining what he/she wants the code to do when using programming languages and he/she is also more likely to be more eloquent in the programming language of choosen.

An experienced programmer is also more likely to make better code, which is more generic or to the point and probably also better at choosing which code should be to the point or generic.

So an experienced programmer is more likely to make better code and because of the eloquence you also get shorter code.

This means shorter code (because of the programmers experience and knowledge) is usually faster and all the other properties you mentioned.

But hey, that is just my opinion ;-)

Reply Parent Score: 2

RE: Eloquence
by Laurence on Thu 27th Sep 2012 11:04 in reply to "Eloquence"
Laurence Member since:

shorter code != faster code.

For instance, if I were writing a video codec, faster and better code would be using hardware frame buffers as opposed to purely software rendering. However using hardware acceleration adds a lot of code as well as complexity.

shorter code != maintainable code.

Modularising code can lead to easier debugging (as classes can be tested in isolation), and better maintainability in many cases too. However modularisation produces more verbose code.

However I think the OP was the most accurate when he stated that "Better code is better because it suits it's task better" - ie there is no definitive rule stating code most comply to x, y and z as the circumstances will vary depending on the project. (case in point, I've written some horrible kludges before because it made the most sense for that particularly project to patch the code in the crudest possible way given the time constraints and the (lack of) significance of the routine that was being patched).

Edited 2012-09-27 11:10 UTC

Reply Parent Score: 5