123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|86|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Question of the Day -> QOTD - Worst Coding Habits?

Page : 1 2 Next
Prev
Tue, 28 Aug 2007, 20:17
HoboBen
There's a lot of bad habits coders can pick up - it might be attempting to make every project a MMORPG and giving up each time, it might be lack of commenting, it might be bad coding style.

Unless you're perfect, then admit it, what's your worst coding habit? And now that you've recognised it, what do you intend to do to solve it?

Personally, I hate commenting. I never do it when I can help it. But I recently read somewhere (insert link here) about a different approach to my newbie every-line commenting, where instead of swamping your code in the stuff, you design your code to be easily readable on its own (so per-line "this obscure rubbish here does this..." comments aren't needed) and instead just write a more detailed comment at the top of each function or block of code, tucked out of the way. I had never really thought of doing that (I used to just comment a huge row of ####s to separate functions from eachother!), but I think it's a much nicer way to do it.

My second bad habit I've only really developed for PHP. Using Cobra, I'm pretty good at writing re-usable units. With PHP, I just copy+paste the same code from place to place and to make it worse, I even change some of the variable names along the way to make it even more difficult to just copy+paste the modified original code across the changed versions. It's not so much a problem after the code I reproduce has matured a bit, because then each separate version evolves to do different things based on their new purpose. But, it's a habit that I should really quit! So, I'm making a resolution to break this one.

How about you?

-=-=-
blog | work | code | more code
Wed, 29 Aug 2007, 00:55
Mog
Hmmm... I obscurely name stuff. Who needs 'Player' when you have 'a', and I tend to hack stuff in without properly structuring it, leading to a confusing mess of ill-named vars doing god knows what.

-=-=-
I am Busy Mongoose - My Website

Dev PC: AMD 8150-FX, 16gb Ram, GeForce GTX 680 2gb

Current Project: Pyroxene
Wed, 29 Aug 2007, 04:30
Afr0
I have a problem with committing to projects that I start, so that I never get to finish them. My solution to this is to try to work in more team oriented projects in the future etc.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Wed, 29 Aug 2007, 04:35
Jayenkai
I'm not as bad at variable naming than I used to be. I used to be really really REALLY bad!
Lately, I've been using a standard selection.
plrx,plry,plrang,plrspd, ect for player
x,y for loops, aimx,aimy for aimed co-ords, scrx,scry for screen scrolling co-ords
bad.die for my baddies, part.icle for particles, bul.let for bullets
and then there's mudown for "Mouse has clicked something, don't allow me to click something else until I've released it"
So, I am getting there! And I've even got to the point where I occasionally go back to old code, stick in something new, with an All New Variable, then find out that I'd already added that variable at the top, for just that very same purpose!


I used to be terrible, though, and I still do occasionally throw in the odd "hippomax" or "piplepop" whenever I need a bizarre never-again-used variable name.


I love Gosubs. Wherever doable, I'll use a Gosub instead of a Function. I don't consider it to be something that's bad.. I see ".label | | Return" the same as I see "function | | End function"


Hobo's second bad habit sounds incredibly familiar, with about 75% of Socoder's script being copy+pasted from the other 25%! Dunno why, but he's right.. It does only happen in PHP!

-=-=-
''Load, Next List!''
Wed, 29 Aug 2007, 05:35
spinal
  • Naming variable poorly
  • Not commenting
  • Bad structuring
  • Never finishing a project


  • -=-=-
    Check out my excellent homepage!
    Wed, 29 Aug 2007, 05:54
    steve_ancell
    My habbits are exactly the same as Spinal's.
    Wed, 29 Aug 2007, 07:13
    Phoenix
    I usually have a problem finishing projects, like many others. But on my current project, when I don't want to work on it, I force myself to code. Anything you code will become boring after a while, but when that happens, you must tell yourself to continue. It's so irritating to throw another project into the trash can.

    |edit| I also have that PHP problem! There must be something wrong with that language. |edit|
    Wed, 29 Aug 2007, 08:51
    JL235
    HoboBen But I recently read somewhere (insert link here) about a different approach to my newbie every-line commenting, where instead of swamping your code in the stuff, you design your code to be easily readable on its own (so per-line "this obscure rubbish here does this..." comments aren't needed) and instead just write a more detailed comment at the top of each function or block of code,

    That's how I try to code. For example instead of writing:

    I'll wrap it all up into a function of it's own so instead it's:

    It's also how programming was taught on my course. Functional languages like Haskell also very much encourage this, where most of your functions will be a single line, with many simply wrapping a couple of functions together.
    Wed, 29 Aug 2007, 16:19
    HoboBen
    That's habit #2 beat!

    Cheers

    -=-=-
    blog | work | code | more code
    Wed, 29 Aug 2007, 16:22
    Jayenkai
    Nice proggy, but how exactly does it help Habit #2?

    -=-=-
    ''Load, Next List!''
    Wed, 29 Aug 2007, 16:24
    HoboBen
    I actually used includes!
    Wed, 29 Aug 2007, 16:30
    Jayenkai
    Oh, right.. Gotcha! Sorry, I thought you meant that the proggy somehow helps reduce Habit 2..
    But it only reduces URLs

    -=-=-
    ''Load, Next List!''
    Thu, 30 Aug 2007, 06:38
    Yayyak
    I've always used HoboBen's new way of commenting, with the function comments and the readable code. My main coding habit that I need to get rid of is to use Over Capitalisation Of CamelCase. EVERYWHERE.

    In C, I have a habit especially of putting Capital letters everywhere, even though the norm is to only capitalise following words, like so:

    Normal people: funcToDoSomething()
    Me: ModuleName_FunctionThatCouldPossiblyDoSomethingSometime()

    AH, you get the point.
    Thu, 30 Aug 2007, 16:48
    power mousey
    a few of mouseys' bad coding habits:

    (1)bad commenting...either too much
    or too little
    Trying to strike a balance of some kind in between.

    (2)Sitting down and coding....but allowing other minor things or minor inconviencies to get in the way. So, I'm coding and doing at least one or more other things at the same time.
    I lose focus and concentration on any of the things/interests that I'm involved with. Rather, than make
    or set a general time period for the task or goal at hand.
    Sometimes my mind wanders on other things too...or even daydreaming or thinking what my next code project will be.

    (3)not keeping some kind of notebook or journal
    for algorithms and routines that I have coded or learned.
    As well as to write down steps,methods,figures for the codes at hand too.
    This is going to change. Cause when I go to the store later on for grocery shopping I'm going to pick up a few notebooks.

    thats about it.
    I know nothing else...right now.


    cheers,
    power mousey



    Thu, 30 Aug 2007, 19:27
    HoboBen
    Mouesy, your #3 sounds like a great idea. I tend to make notes on the computer, and save them somewhere where I'll never see them again!

    Then again, I tend to lose physical notebooks too

    -=-=-
    blog | work | code | more code
    Thu, 30 Aug 2007, 19:37
    mindstorm8191
    I have the bad habit of giving important global variables difficult names, or names that should be something else. Then, I either can't remember what they're called, and have to go look it up, or keep trying to use one variable name for something else. Like in my current project, the player's space ships can have parts added onto it. But in the code, I decided early on to call them all pieces. But I still want to call them parts in the code (and comments). Ends up with a ton of confusion.

    As far as other people's code, the two bad habit I hate worse is for people to leave their code totally uncommented (I like HoboBen's new comments approach best), and for people to not put any tabs in their code. Without tabs I have to then run through the entire code, adding tabs to each line, and making sure everything lines up and is tabbed correctly. Very tedious...

    -=-=-
    Vesuvius web game
    Thu, 30 Aug 2007, 19:38
    JL235
    I've got a notebook too. It's just the right size to have plenty of room to draw and write too, whilst being small enough not to get in the way. I used to love the idea of making notes, but the practicality always confounded me because I was using A4 sized books. The new system of having a smaller notebook is a HUGE benefit. I just turn the page and write and try ideas, and when I want to go over something I did the over day I just turn back. Perfect.

    My desk also helps too, cos it goes back slightly further then an office desk and so I can have the keyboard behind my notes easily accessible for typing, and the notepad still ready for writing. Perfect.
    Thu, 30 Aug 2007, 20:56
    power mousey

    thats really a good idea and really cool.
    and what a coincidence, DiablosDevil.

    I just bough some small notebooks too.
    A pack of 3 in one and over at Safeway too.

    And talking about your desk...
    my brother Mark bought me a big computer table
    to put my computer and monitor on.
    Yet, I'm just using it to store and place other things
    on it. My computer is still near the edge of the kitchen
    counter while my monitor and keyboard is on this small
    picnic like table. Also, my other computer is sitting on it too. And as a Desktop paperweight.


    cheers
    power mousey

    Fri, 31 Aug 2007, 04:20
    Jayenkai
    Yep, notepads are definitely handy. I don't use mine much, but whenever I do, the ideas, and more importantly the Maths tend to flow a little quicker.
    I have two.. One is my Most Used, the other is my "More important stuff" pad, but it doesn't seem to be getting any usage at all!!
    The Most Used pad goes right back to some of my really early Blitz stuff, with lots of random ideas jotted down. Mostly database layouts, but occasionally silly little sketches and things.
    I've been considering doing a section on my Blog, whereby I scan in old pages, and pop them up, along with the resulting game.

    -=-=-
    ''Load, Next List!''
    Fri, 31 Aug 2007, 10:49
    Evil Roy Ferguso
    My biggest problems are probably:
    • Never finishing anything
    • Trying to add on functionality in the way that takes the least time to add in, rather than the way that is best structured or most efficient. This once led me to create a constant, ENEMYSTATE_ZOMBIE_IS_ACTUALLY_A_HAT -- 'hats' acted the same way as zombies except for one or two minor differences, so hats were stupidly implemented as a state of zombies instead of a new kind of enemy. I think constants like ENEMYSTATE_ZOMBIE_IS_ACTUALLY_A_HAT should just about always serve as an immediate sign that something is horribly wrong.

    Fri, 31 Aug 2007, 10:54
    power mousey

    haha

    Not the band Men With Hats and their
    song of The Safety Dance.
    Zombies wearing hats.

    but what does this variable mean?
    ENEMYSTATE_ZOMBIE_IS_ACTUALLY_A_HAT

    whew!!! all that typing for just one variable.
    you must get zombied out.


    cheers,
    power mousey


    Fri, 31 Aug 2007, 17:41
    mindstorm8191
    I like the idea of having a notebook for projects. I actually have a binder with a bunch of folders in it, each containing some papers on a project or two. In the past I have found that writing problems down on paper can help immensely in solving complex problems. Sometimes a few lines on a paper can keep you from writing guess-work code. Come to think of it, I know another bad habit of mine - I don't seem to use paper anymore for projects.

    Another thing I like to do, I have a tiny notepad I carry with me in my pocket (I call it a pocketpad). I use it to write down important information (most of it isn't related to programming), and when I have nothing better to do I'll open it up and jot down notes on programming, as I start planning projects out. The trouble is, as a project develops further along, there isn't much I can really do with the pocketpad, as all my code is on the computer, and there isn't much I can do non-coding wise.

    I seem to have the opposite problem of Evil Roy - I try to plan things out in too much detail, and anything new I want to add, I want to restructure the entire system so the new ideas can work seamlessly with it. Then, when I am designing the system at the beginning, I spend too much time worrying about having the best, most efficient system possible, even when I don't know all the ideas I'll incorporate into the code.

    -=-=-
    Vesuvius web game
    Tue, 04 Sep 2007, 07:45
    skypenguin
    Safeways!! I haven't heard that name in a while, ever since Morissons took over the UK branch

    My bad habits are

    1) Using too many if statement in PHP

    2) Setting far too many cookies that I never use in PHP. Infact, once, I set every variable as a cookie

    3) When connecting to DB's, I normally use the includes function to include dbconnect.php, but then, I but a db connect script in the script aswell

    4) Almost always forget to use mysql_close()

    5) Miss out semicolons a lot



    Thu, 06 Sep 2007, 16:34
    Forklift_Fred
    My biggest bad coding habit has got to be not coding!

    This leads to problems when I try to start again because I can't remember anything

    But when I am coding... Comments are a prime suspect. I used to go over board because I was still learning and wanted to be able to follow what I was doing when I came back to it and I think it helped clarify what I was doing at the time. The result was a file twice the size it needed to be.

    On the other hand I can get caught up with getting it working and forget to comment so I end up with a random scattering of comments.

    Next up, we have the problem of not planning first. I'll have an idea of what I want to end up with and an idea of how I'll achieve it but I'll always start coding way too early and want to see results before it's ready to show any.

    And finally, trying to walk quickly before I can crawl. Not as bad a running before you can walk because I know my limits but I still have projects that push my abilities a little too far for the time and effort I'll end up putting in.



    -=-=-
    Come rain or shine...
    Sat, 08 Sep 2007, 17:00
    Teasy
    Or what about the infinite objectivity habit?
    For example if I need a routine that draws a filled rectangle on screen.
    So, a few coordinates and dimensions and I'll be done.

    Instead of just focussing on that and finishing it, my brain likes to 'make the world a better place'.
    So, while coding the routine, I get these questions of perfection and my brain follows them without thought.

    For example, why not enhance the routine to use any color? I might need that in the future.
    And while I'm at it, why not add the ability to draw just the outline of the rect, instead of only filled.

    Ah but wait, I could also make it rotate..
    Yeah, that's cool, and using a pivot point, with scaling.

    No wait, I'll rewrite it so it'll be a polygon function, so I can also use to draw triangles.
    Naah, I'll just go right ahead with my vector system, using vector objects, so I can use any shape.

    ..5 hours later..

    Well, that vector system is gonna take a lot longer than expected.
    I guess I'm not gonna be able to draw a rectangle to the screen today

    One of my tutorials is also suffering from this problem
    5 partial rewrites and about a dozen attempts in completely different directions.
    But I think I've found the trick!
    Hint: make it easier for yourself.

    |edit| Ooh! Sounds a bit like mindstorm8191's habit |edit|
    Sat, 08 Sep 2007, 17:08
    Jayenkai
    LOL! That's definitely true, and I certainly find myself doing that a lot, lately.
    Sometimes keeping things simple means you actually get some proper coding done!

    -=-=-
    ''Load, Next List!''
    Page : 1 2 Next
    Prev