Bad Habits

We know you've got some... what are they?

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 3274 Views - Last Post: 09 October 2007 - 12:10 AM

#1 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1812
  • View blog
  • Posts: 20,232
  • Joined: 17-March 01

Bad Habits

Post icon  Posted 07 September 2007 - 02:21 PM

We all take short cuts when we code, and maybe you come back and clean them up, but what are some of the bad habits you have when coding?

For me, it's not scoping my variables, and not using OO all the time. For little things, I'd rather just code it up real fast using the ole top down approach. I also use SELECT * a bunch when writing queries which is bad because I rarely need all the fields.

What are your bad habits?

Is This A Good Question/Topic? 0
  • +

Replies To: Bad Habits

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3872
  • View blog
  • Posts: 11,405
  • Joined: 18-April 07

Re: Bad Habits

Posted 07 September 2007 - 02:56 PM

Sometimes I catch myself using the obscure variable name but as soon as I put it down I always go back and rename it two seconds later. One because it irritates me and two I want to force myself into good habits. Maybe I dive into code a little too soon sometimes before fully planning something out but I have been working on that one as well.

:)
Was This Post Helpful? 0
  • +
  • -

#3 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 199
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: Bad Habits

Posted 07 September 2007 - 03:04 PM

i'm with you Chris, sometimes I am in a rush to finish I just make it work, and don't worry about efficiency, effectiveness, or even consider other approaches to solve the problem... I blame University giving me 2 weeks (with 4 other courses of work and work itself) to do 1000-3000 line programs from scratch... often without discussing the topics ahead of time.

Justified or not, I try to break this habit when I write code for personal use.. but sometimes you just need it to work... and remembering to fix it can tough, lol
Was This Post Helpful? 0
  • +
  • -

#4 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: Bad Habits

Posted 07 September 2007 - 06:13 PM

I tend to really rush the last 10% of the project...it's always the most interesting part, but I'll end up rushing through it because I want it done with - this leads to shoddy code, most of the time. :(

I do the same thing with SELECT * as Skyhawk does.

And I tend to play around with scope a bit too much. Things like this:
while($sth->fetch) {
	my $sth = $dbh->prepare("SELECT * FROM users WHERE clue > 0");
	## blah blah blah
}


Was This Post Helpful? 0
  • +
  • -

#5 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 3509
  • View blog
  • Posts: 27,641
  • Joined: 21-March 01

Re: Bad Habits

Posted 08 September 2007 - 02:25 PM

in the app i am currently programming i have used the variable boner and boner2 about 100 times.
Was This Post Helpful? 0
  • +
  • -

#6 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 64
  • View blog
  • Posts: 3,505
  • Joined: 31-March 03

Re: Bad Habits

Posted 08 September 2007 - 02:37 PM

I'll use very short variable names...like $a, $b, $q, $t, etc. However my style of coding consisting of mainly class/methods and functions, so I don't run into naming conflicts often.
Was This Post Helpful? 0
  • +
  • -

#7 Oaty  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-May 07

Re: Bad Habits

Posted 08 September 2007 - 03:01 PM

The bad habit I hate committing the most is copying and pasting some code that should really be part of a function or routine somewhere.

For example, when generating html for 5 icons I'll get it to work once and then copy/paste it four more times only changing the SRC attribute.

"That's bad and will bite you later." my Conscience says...
"Shut up I have to have it done by the 2 o'Clock meeting and it works." I rebut through gritted teeth
Was This Post Helpful? 0
  • +
  • -

#8 ap0c0lyps3  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 19-June 07

Re: Bad Habits

Posted 10 September 2007 - 04:05 AM

Not planning before starting a project and not using OOP and I always seem to forget finishing a function or something.
Was This Post Helpful? 0
  • +
  • -

#9 bigdawg24  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 288
  • Joined: 18-August 07

Re: Bad Habits

Posted 10 September 2007 - 07:59 AM

View PostOaty, on 8 Sep, 2007 - 03:01 PM, said:

The bad habit I hate committing the most is copying and pasting some code that should really be part of a function or routine somewhere.

For example, when generating html for 5 icons I'll get it to work once and then copy/paste it four more times only changing the SRC attribute.

"That's bad and will bite you later." my Conscience says...
"Shut up I have to have it done by the 2 o'Clock meeting and it works." I rebut through gritted teeth


Yes I have seen myself in this same boat before as well. Although I have seen a co-worker of mine actually make a decent first page and not do anything until crunch-time (the time after he procrastinated and now the project is due) and have pretty much just a background for the rest of the site. It's almost humorous... until I am the one on the weekend correcting it.
Was This Post Helpful? 0
  • +
  • -

#10 tody4me  Icon User is offline

  • Banned
  • member icon

Reputation: 12
  • View blog
  • Posts: 1,398
  • Joined: 12-April 06

Re: Bad Habits

Posted 10 September 2007 - 09:54 AM

my bad habit is the lack of commenting in code. i usually don't use comments except now in C# i use the summary and parameters to describe the functions, where previously i didn't use them much in vb.
Was This Post Helpful? 0
  • +
  • -

#11 UltraFlynn  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 136
  • Joined: 03-August 07

Re: Bad Habits

Posted 10 September 2007 - 02:18 PM

My worst bad habit is probably that I find it hard to accept some coding standards of the companies I work for it they are totally against what I'm used to doing. Generally I'll try to sneak in my own preferences and see if anyone notices.

The last bank I work for wouldn't let me code if statement like this:

if (...) {
}

they insisted on this:

if (...)
{
}


which used to drive me crazy and I fought against it for ages.

The other bad habit stems from using Eclipse. It actively encourages you to refactor. You see a method named wrong, double-click, hit Shift-Alt R, rename, then watch as Eclipse trawls through all the necessary classes and mends everything. It's obviously the right thing to do but you keep having to explain yourself why a simple code change has resulted in so many affected files.
Was This Post Helpful? 0
  • +
  • -

#12 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 175
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Bad Habits

Posted 11 September 2007 - 05:09 AM

HAHA, you really can't do much about it.
Everyone has their own indenting styles.
I usually use the latter.

I guess they forced the indentation style to maintain readability across the entire code.
Was This Post Helpful? 0
  • +
  • -

#13 1lacca  Icon User is offline

  • code.rascal
  • member icon

Reputation: 44
  • View blog
  • Posts: 3,822
  • Joined: 11-August 05

Re: Bad Habits

Posted 11 September 2007 - 05:45 AM

An indentation guide is like the most idiotic thing I've ever come across, since the most basic IDEs support the feature to indent your code with a keypress to whatever format you prefer, so it's like totally unnecessary to bug the programmers with it - actually none of the more professional places I've been to required it. (If it is so important and mission critical for the company run an identator app on the version control server)
Just to make it clear: I am not agaisnt correct indentation (it's really essential), but against forcing one format onto everybody.
Was This Post Helpful? 0
  • +
  • -

#14 UltraFlynn  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 136
  • Joined: 03-August 07

Re: Bad Habits

Posted 11 September 2007 - 06:25 AM

I'd agree with that. I actually quite like all the programmers to have similar but different styles. It makes it easy to see what you coded and what you can trust.
Was This Post Helpful? 0
  • +
  • -

#15 jp42  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 21-August 07

Re: Bad Habits

Posted 11 September 2007 - 07:51 AM

What I cannot stand are the crappy, poorly thought out and written requirements that the supposed "Project Managers" I work with create. They are not technical but its a requirements doc, why the h**l cant they just clearly and explicitly state what they want? Ok, Ill get off my soapbox...--jp
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2