What is your preference? Do you prefer to have large code but that is easy to understand, or short code that can be done with large code but that is... Harder to understand? I don't know why, but personally, I always thought that one of the programming goals a programmer had was to have easy to understand code for maintenance, however, I have seen people that opt to go for the short code that is harder to understand, even thought many of them don't know how exactly their short algorithm works. Is programming showing that you can make a good maintainable program, or are you more interested in showing off your complex math skills? I am not good at math (hate it, in fact), so I obviously opt to use long code, and sometimes when people try to shorten my code, I don't do it because my code should be easy for me to maintain and understand.
Any comments welcome!
Large Code Versus Short Code.Easy To Understand Code, Versus Hard To Understand Code.
18 Replies - 2379 Views - Last Post: 09 August 2009 - 07:54 AM
Replies To: Large Code Versus Short Code.
#2
Re: Large Code Versus Short Code.
Posted 14 July 2009 - 07:48 AM
i think it depends from user to user.
if some large block of code make you understand somethink better, i think that you will figure some way to make it better next time...so less code
if some large block of code make you understand somethink better, i think that you will figure some way to make it better next time...so less code
#3
Re: Large Code Versus Short Code.
Posted 14 July 2009 - 08:03 AM
It depends on what the code is doing and how much performance is a factor. Other then that, well-commented short code.
#4
Re: Large Code Versus Short Code.
Posted 14 July 2009 - 08:13 AM
I'm a functional programmer. We tend to lean towards concise code, but if done correctly, it should still be highly readable. Besides that, with comments and such...
#5
Re: Large Code Versus Short Code.
Posted 14 July 2009 - 08:17 AM
I think I am a very neat programmer. I tend to overcode, but I like to make sure that everything is there. There's nothing that aggrivates me more than going back to add 15 new methods because I didn't prepare.
Also, although it's long, my code is pretty well documented and organized into blocks. It's quite obivious where something is in my code. You can tell by my pattern.
Also, although it's long, my code is pretty well documented and organized into blocks. It's quite obivious where something is in my code. You can tell by my pattern.
#6
Re: Large Code Versus Short Code.
Posted 22 July 2009 - 05:01 AM
I like to use short code that semi-documented. So for example, if I've got something like an ArithmeticException, I'll usually name it ae or something like that so I know which object I'm talking about... then if I've got more than one of the same object, unless there's some specific reason for it, I'll usually just make it into an array or list. I prefer whitespace over indentation and the like though, so my code usually ends up longer anyway, even though there may be only one or two words per line...
#7
Re: Large Code Versus Short Code.
Posted 22 July 2009 - 07:21 AM
I'd rather have short code, but only if it's clever.
#8
Re: Large Code Versus Short Code.
Posted 22 July 2009 - 07:49 AM
Short code - with comments, and if its quite alot of code I seperate similar functions and/or precedures it into seperate modules/classes.
Why I do this? because I dont like scrolling up and down a mile.
Why I do this? because I dont like scrolling up and down a mile.
#9
Re: Large Code Versus Short Code.
Posted 22 July 2009 - 07:50 AM
Well, sometimes classes just need lots of methods!
#10
Re: Large Code Versus Short Code.
Posted 22 July 2009 - 01:23 PM
whatever will run faster. I dont care if its longer or shorter, as long as its the best way and faster way that i know how to get a result, thats what i use.
#11
Re: Large Code Versus Short Code.
Posted 25 July 2009 - 12:32 PM
I try to keep code short, but I also try to make sure that my code has good verbosity.
#12
Re: Large Code Versus Short Code.
Posted 25 July 2009 - 03:48 PM
IMO, when you are writing code, you should always try to write it so that if you have to come back to in a year or two you can easily see your thought patterns at the time and it should be easy to understand what your intention was. What I mean it might take a while longer to type:
than
when you come back to the code at a later date it is easier to understand what your intentions were by using descriptive names.
You could always write it in short hand until you perfect the code and then refractor to the longer, more descriptive variable names I guess. You could also, once the code is perfected, look for optimizations that will speed up the bottle necks in the code as well.
TimeSpan lastUpdate;
than
TimeSpan lu;
when you come back to the code at a later date it is easier to understand what your intentions were by using descriptive names.
You could always write it in short hand until you perfect the code and then refractor to the longer, more descriptive variable names I guess. You could also, once the code is perfected, look for optimizations that will speed up the bottle necks in the code as well.
#13
Re: Large Code Versus Short Code.
Posted 25 July 2009 - 04:08 PM
Crimson Wings, on 14 Jul, 2009 - 07:29 AM, said:
What is your preference?
Without other constraints, comprehension wins. Even if the code is very terse and compacted, the comments around it should ensure complete comprehension of how the algorithm works.
This post has been edited by sscheider: 25 July 2009 - 04:10 PM
#14
Re: Large Code Versus Short Code.
Posted 05 August 2009 - 06:18 AM
i do it moderately....
too short is not kinda good since you add comment here and there...
me like using basic thing together wit clever function...
too short is not kinda good since you add comment here and there...
me like using basic thing together wit clever function...
#15
Re: Large Code Versus Short Code.
Posted 05 August 2009 - 10:08 AM
I think it's a delicate balance.. sometimes overly verbose code can be hell to wade through, and turning it into a block of compact code with a comment would really improve readability.
This post has been edited by c0mrade: 05 August 2009 - 10:09 AM
|
|

New Topic/Question
Reply



MultiQuote













|