Large Code Versus Short Code.

Easy To Understand Code, Versus Hard To Understand Code.

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 3073 Views - Last Post: 09 August 2009 - 07:54 AM

#1 Crimson Wings  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 13
  • View blog
  • Posts: 215
  • Joined: 11-July 09

Large Code Versus Short Code.

Posted 14 July 2009 - 07:29 AM

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!

Is This A Good Question/Topic? 1
  • +

Replies To: Large Code Versus Short Code.

#2 Bocard  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 222
  • Joined: 24-September 08

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 :P
Was This Post Helpful? 0
  • +
  • -

#3 brucet  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 20
  • Joined: 13-July 09

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.
Was This Post Helpful? 0
  • +
  • -

#4 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

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...
Was This Post Helpful? 0
  • +
  • -

#5 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2635
  • View blog
  • Posts: 15,654
  • Joined: 24-September 08

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. :D
Was This Post Helpful? 0
  • +
  • -

#6 Jaakuuta  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 163
  • Joined: 02-July 09

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...
Was This Post Helpful? 0
  • +
  • -

#7 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

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.
Was This Post Helpful? 0
  • +
  • -

#8 PDUNZ  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 43
  • View blog
  • Posts: 372
  • Joined: 17-July 09

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.
Was This Post Helpful? 0
  • +
  • -

#9 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2635
  • View blog
  • Posts: 15,654
  • Joined: 24-September 08

Re: Large Code Versus Short Code.

Posted 22 July 2009 - 07:50 AM

Well, sometimes classes just need lots of methods!
Was This Post Helpful? 0
  • +
  • -

#10 bflosabre91  Icon User is offline

  • go sabres

Reputation: 105
  • View blog
  • Posts: 1,439
  • Joined: 22-February 08

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.
Was This Post Helpful? 0
  • +
  • -

#11 sparkart  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 113
  • View blog
  • Posts: 688
  • Joined: 16-February 09

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.
Was This Post Helpful? 0
  • +
  • -

#12 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

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:

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.
Was This Post Helpful? 0
  • +
  • -

#13 sscheider  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 55
  • Joined: 14-May 09

Re: Large Code Versus Short Code.

Posted 25 July 2009 - 04:08 PM

View PostCrimson 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

Was This Post Helpful? 0
  • +
  • -

#14 100+PluS+  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-August 09

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...
Was This Post Helpful? 0
  • +
  • -

#15 c0mrade  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 412
  • Joined: 16-November 07

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

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2