Bad Habits

I’m guilty of coding in a single class 90% of the time (I have other classes in my classes, not separated). My code isn’t organized like anyone around here would normally organize, my packages are simply “game” and my classes are just the name of said game. (It’s fine though, I’m bad, and I don’t share my code with others, so I’m not leading anyone else to OOP hell.)

What poor coding habits are you guys guilty of?

I don’t comment. Period.

Somewhat excessive attempts at code organization, even for private code. I spend more time working on that than anything else.

Always encapsulating data. Even when it leads to a lot of boiler plate style code. I only just broke the habit in a project I’m working on right now. I’m actually using public fields.

Prematurely optimizing code.

Commenting after I code.

Bad habits are only really bad habits if they hinder you or the program.

Laziness is fine and even positive as you get things done more efficiently, so I wouldn’t say lack of commenting is bad unless you work in a team.

My #1 bad habit is scope creep.

Reading up on threads instead of actually programming. runs

If I have comments then it’s just code that I don’t want running. All dem //system.out.println() comments…

^+1 :D:D

Spending weeks planing the perfect code layout without writing a single line of code…

My worst habit is probably writing “test” code in a lot of my classes, cluttering them up and then never removing or refactoring the test code because it worked so well! My classes get very messy :frowning:

After you write some code that does something special/important, always think if it will be instantly understandable if you look at it in 6 months… if it’s complicated then I say comment it.

I use good variable names so you don’t need to comment, but often I find some variables aren’t name-able and when your variable names are too long It’s hard to read (I like some equations on a single line okay? The readability of the equation is sometimes more important than the variable names - since the variable names don’t always represent real-world things. I hope that makes sense.)

When I use short variable names in complex algorithms and equations, I always comment my code.

Of course, this goes out the window if you REALLY think you’ll code the entire project in a few months.

Every single line of code I type, I press crtl-a and ctrl-shift-f along with crtl-s to format and save it. They’re the only hot-keys I use and I rarely copy and paste code. Also, when I don’t like the design of something, I sometimes spend hours re-factoring it if there’s a lot of code. With practice though I seem to be getting faster at refactoring, which I guess is a handy skill to learn.

I like to be able to diagonally read code so short variable names rule.

My sin: reading too much research on things that I don’t need on that day.

My code always looks great. Formatting, naming conventions, commenting, etc. all comes very natural and I do it as I code. Though, I have a habit of spending too much time on the framework of new projects. I spend so much time trying to make development time quicker, that it kind of loses its point.

I do this one as well. I’ve read all sorts of the LWJGL topics around here, and other places, and I refuse to touch it, or any direct openGL binding. It scares me too much.

I encapsulate nearly everything and afterwards I implement that encapsulated “object” in a static way ::slight_smile:
If I only need one object :clue:


public Class Dummy{ 
public static Dummy dummy;
[...]
}

While thinking about it, it might isn’t that bad,
because it’s easy to modify it. But maybe I just need it because even if I try to plan everything it will become different ;D
Commenting is just for people who are afraid of thinking about their code again and again and again 8)

I comment too much… :stuck_out_tongue:

I don’t document my code at a high enough level. I document the nuts and bolts of classes and methods well enough, but I find myself coming back to code later thinking…why did I do it this way? Why is this an interface? What was I planning on using this class for?

I find myself much more productive when I document my intentions. Something like: “My Action class is part of a GOAP framework. The idea is that all other Actions will inherit from this class and then only need to implement the update, onSuccess, and onFailure methods. These actions should really only be used when a GameEntity needs to do something that takes more than one time step.”

This kind of document doesn’t really fit into javadoc and needs its own file.

I have horrible posture… Feels good now, but later it will be a (literal) pain in the back.

But in all seriousness, it is good to have better posture. It will help your back over time, and it’s healthier! However, do not sit at 90* degrees!

Also, I have NEVER looked deeper into other programming languages!

My bad habits are, starting a project writing a few basic classes usually as far as getters and setters, then get bogged down with trying to figure out how to tackle the game loop and then that it.

Its a terrible habit.

Oh actually i have another habit actually, i decide today will be the day i program, black out what the? how have i managed to login to a game and start playing well never mind i might as well continue playing until i am bored and thats really the story of my life, my life slowely evaporating due to a gaming addiction.

I personally never game anymore, except for the occasional match of Battlefield bad company 2, BF3 and soon BF4! Something about the BF series really just does it for me like no other game can! But still, I game maybe 2 hours a week at max, its just not fun anymore when I know I have code to work on!