Untidy Code

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 2731 Views - Last Post: 14 February 2012 - 04:28 PM

#1 javaHeyy  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 12
  • Joined: 08-February 12

Untidy Code

Posted 10 February 2012 - 06:54 PM

Is it just me, or is untidy code extremely f*cking annoying? I find the guys I study with make me want to hit them and their sloppy code right in the jaw.
Is This A Good Question/Topic? 3
  • +

Replies To: Untidy Code

#2 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 922
  • View blog
  • Posts: 3,195
  • Joined: 19-January 10

Re: Untidy Code

Posted 10 February 2012 - 07:06 PM

I find that whenever I'm helping someone out with some error, it's mainly because of untidy code. I have to ask them what each variable is and what it contains and half the time they don't even know. Some people will just pound away at the keyboard trying to see what sequence of lines will produce what they want.

so, yeah. I agree.
Was This Post Helpful? 0
  • +
  • -

#3 javaHeyy  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 12
  • Joined: 08-February 12

Re: Untidy Code

Posted 10 February 2012 - 07:33 PM

Yeah, I often encounter it when helping people out. Like once I came across a for loop with no indentation at all... like below.
for(int i = 0; i < Employees.size(); i++) {
all.write(Employees.get(i).print());
Employees.get(i).print();
}

I fixed it up, added some indentation, and he had a rage because now he couldn't "read" it. I've never helped him since.
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,351
  • Joined: 29-May 08

Re: Untidy Code

Posted 10 February 2012 - 11:05 PM

On indentation 2 spaces is enough not the 4+ VS likes to enforce, having to scroll to the right is not good.
Was This Post Helpful? 0
  • +
  • -

#5 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

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

Re: Untidy Code

Posted 11 February 2012 - 01:38 AM

Languages that make 4+ indentation standard piss me off.
Was This Post Helpful? 0
  • +
  • -

#6 The Architect 2.0  Icon User is offline

  • D.I.C Regular

Reputation: 37
  • View blog
  • Posts: 351
  • Joined: 22-May 08

Re: Untidy Code

Posted 11 February 2012 - 05:33 AM

i kinda like 4 spaces :D

I personally use guard-clauses to reduce right-arrow code.
Was This Post Helpful? 0
  • +
  • -

#7 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,355
  • Joined: 02-June 10

Re: Untidy Code

Posted 11 February 2012 - 06:18 AM

View PostAdamSpeight2008, on 11 February 2012 - 12:05 AM, said:

On indentation 2 spaces is enough not the 4+ VS likes to enforce, having to scroll to the right is not good.


Turn on word wrap and you don't have to side scroll.

Attached Image

Use a second monitor for your pallets, giving you a dedicate monitor for code editing. If you are trying to cram in both code and pallets on one screen then you are either wasting lots of time with the pallets auto-open/closing or you have no space left for your text.

Attached Image

This 3 monitor layout gives me a third monitor free for the running/debugging application without coving code or pallets.
Was This Post Helpful? 0
  • +
  • -

#8 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,355
  • Joined: 02-June 10

Re: Untidy Code

Posted 11 February 2012 - 06:30 AM

View PostRaynes, on 11 February 2012 - 02:38 AM, said:

Languages that make 4+ indentation standard piss me off.


Its not the language its the IDE. If you don't like it: Fix it.

Attached Image
Was This Post Helpful? 2
  • +
  • -

#9 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

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

Re: Untidy Code

Posted 11 February 2012 - 03:06 PM

Except for those formatting standards things. Who cares about those though, right?
Was This Post Helpful? 0
  • +
  • -

#10 ishkabible  Icon User is offline

  • spelling expret
  • member icon





Reputation: 1616
  • View blog
  • Posts: 5,707
  • Joined: 03-August 09

Re: Untidy Code

Posted 11 February 2012 - 04:24 PM

most languages don't really have them. C++ is pretty bad about that. also, so long as you keep your lines no more than 80 long it's not an issue. Of course sometimes it's really hard to fit a line into 80 characters and you have to spill over into the next line :/

all that said, I actually like 4 space indents; I hate more than 4(8 kills me), I Like 3 just as much as 4 and can live with 2. what I really hate is not being able to fit relevant chunks of code on the screen so I try to cut down on my number of lines as much as possible.

besides, I have more real-estate from side to side than I do up and down. still, I try to conform to the 80 length rule.

Quote

Is it just me, or is untidy code extremely f*cking annoying? I find the guys I study with make me want to hit them and their sloppy code right in the jaw.


I'm dreading working with beginners in my college classes; I'm kinda wondering what the repercussions of me doing all the work would be :/ I feel like it would be doing them a disservice and would possibly get me in trouble.

This post has been edited by ishkabible: 11 February 2012 - 04:29 PM

Was This Post Helpful? 0
  • +
  • -

#11 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1906
  • View blog
  • Posts: 3,949
  • Joined: 11-December 07

Re: Untidy Code

Posted 11 February 2012 - 07:46 PM

Poorly formatted code is difficult to read, plain and simple. But that's not an excuse! Any IDE worth its salt has commands to correct the indentation or reformat a whole section of code. I'm sure there are plenty of standalone utilities only a google away if you need them too.
Was This Post Helpful? 0
  • +
  • -

#12 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 856
  • View blog
  • Posts: 2,246
  • Joined: 28-March 11

Re: Untidy Code

Posted 11 February 2012 - 07:49 PM

I hate code that uses tabs instead of spaces, or an editor that does not convert a tab press into the amount of spaces I want.
Was This Post Helpful? 0
  • +
  • -

#13 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7292
  • View blog
  • Posts: 12,099
  • Joined: 19-March 11

Re: Untidy Code

Posted 13 February 2012 - 12:53 AM

If your lines are too long, your code is no good. Chained method calls can be split across lines:
Format f = Format.getRawFormat().
           setEscapeStrategy(someEscapeStrategy).
           setExpandEmptyElements(true).
           setLineSeparator(lineSep).
           [ blah blah blah ]




and String concatentations can be handled similarly.

But if indentation is pushing you off the right end, it's time to refactor that mother.


As for tab widths, tabs vs. spaces, and the like - you define a house style and stick with it. If you're supervising a project and you can't get someone to obey local coding conventions, one of you needs fired.

(really, it should be the developer, because if you can't figure out how to make your environment do what you want, you probably need to get schooled on someone else's time)
(or else it should be the manager, because they clearly can't manage to manage)

(or just get rid of both of them...)
Was This Post Helpful? 1
  • +
  • -

#14 Aphex19  Icon User is offline

  • Born again Pastafarian.
  • member icon

Reputation: 614
  • View blog
  • Posts: 1,873
  • Joined: 02-August 09

Re: Untidy Code

Posted 13 February 2012 - 02:14 AM

View PostGunnerInc, on 11 February 2012 - 07:49 PM, said:

I hate code that uses tabs instead of spaces, or an editor that does not convert a tab press into the amount of spaces I want.


That's the exact attitude I have when writing Haskell code, but surely it wouldn't make much difference with other languages that don't really care about tabs and formatting.

This post has been edited by Aphex19: 13 February 2012 - 02:16 AM

Was This Post Helpful? 0
  • +
  • -

#15 e_i_pi  Icon User is online

  • = -1
  • member icon

Reputation: 782
  • View blog
  • Posts: 1,662
  • Joined: 30-January 09

Re: Untidy Code

Posted 13 February 2012 - 04:45 AM

Speaking of which, has anyone seen what SSMS does with CREATEd views? I'd like to personally thank whichever Microsoft employee came up with that labyrinthine mess, as I happily charge out at $50/hr to clean it up before debugging it.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2