Page 1 of 2

Best and worst game-making habits (forum-game)

Posted: Sat Jan 08, 2011 4:05 pm
by Taehl
I had an idea for a forum game which would both entertain and inform. Quite simply, each poster advises readers of one of their good habits (best practices that prevent bugs, save development time, prevent code messiness, etc.) and warns them against their bad ones (things that always end up causing them problems, solutions that can't be expanded, anything you know you shouldn't do but you do anyway, etc.), and says why they're good/bad. Let's keep these relevant to programming and game-making in general, please. I'll start:


Best:
I leave a lot of comments in my code. Whenever I make a new function, I first put a comment above it explaining what it does, and I leave frequent (if terse) notes along the way. This is a great habit because it helps you understand your own code a little better, sometimes makes logical inconsistencies more evident, and (most importantly) is a MAJOR help to anyone else looking at your code.

Worst:
I tend to use non-descriptive, single-letter variable names. For example, in my current project is the line "if w then t.w,t.h = w+(t.w or 0), h+(t.h or 0) end". As you can see, that isn't very meaningful. Not only does it make it hard for others to understand, if you're not careful, there's a chance even YOU may forget what all those mysterious variables represent, which is no good.

Re: Best and worst game-making habits (forum-game)

Posted: Sat Jan 08, 2011 5:03 pm
by nevon
Best:
Super-strict indentation. I come from a Python background, where proper indentation is required for the code to even run (correctly), so I always, always, always indent my code properly.

Worst:
Unhelpful comments. If I leave comments at all, they often explain what something does, and not why. This often happens when I'm not 100% familiar with some built-in function, and so I document what it does for future reference. But for someone who's already familiar with the language I'm using, the comment would be completely useless.

Re: Best and worst game-making habits (forum-game)

Posted: Sat Jan 08, 2011 5:19 pm
by TechnoCat
Best:
Good indentation and code-block readability (Also because of strict python guides). I try to make any code I do modular so it is easily extendable and debugable. I also try and make all my code open source so anyone can benefit from it or even help me if they see something that can be improved.

Worst:
The biggest of the worst habits I do and most everyone here does is: Never finishing a project you started.
Often sparse comments because I just forget to or I am on a coding roll. I try to optimize my code when it isn't necessary or just too early to.

Re: Best and worst game-making habits (forum-game)

Posted: Sat Jan 08, 2011 8:21 pm
by BlackBulletIV
Best:
Splitting code up into multiple functions, classes, etc. AND files. Reading a gigantic function is hard work, as it is for classes and the like. What's even harder is reading a file that's a few thousand lines or more; that's painful. Splitting up code will help organisation, save headaches later, and really help newcomers.

Worst:
Trying to minimise code lines! Jamming as much code in a line as possible and not using blank lines makes code hard to read. It's like trying to read a bunch of English without paragraphs (it's hard). Using a lot of meaningful blanks (but not anymore than necessary) and not jamming in lots of code into a line will help you later on, and seriously help any newcomers.

Re: Best and worst game-making habits (forum-game)

Posted: Sat Jan 08, 2011 9:45 pm
by Lap
Best: I typically make every possible aspect of my games able to be turned off, modified or added to. I do this because I love community mods and because it saves a lot of time if I change my mind about something. Make things modular!

Worst: Too many bad habits, but most have already been said so I'll go with...Global namespace pollution. I move around functions in between files all the time and I really hate forgetting which files are being loaded first. I've since become lazy and I don't really use locals as much as I should. Unfortunately, this habit directly hinders modders :P

Re: Best and worst game-making habits (forum-game)

Posted: Sat Jan 08, 2011 10:58 pm
by ishkabible
best:
splitting every class into it's own file and not optimizing prematurely(i tend to try and reduce complexity prematurely however)

worst:
sacrificing readability for ease of typing and reducing complexity in disregard for ease of thought and weather or not it needs to be done. also in Lua im really bad about using globals, i would make a game state for my games but i never feel the need.

Re: Best and worst game-making habits (forum-game)

Posted: Sat Jan 08, 2011 11:24 pm
by tentus
Best:
I tend to make my code as user-proof as possible, by providing default values, checking types, etc. This protects me from myself and anyone who might be trying to use my code without a full understanding of it.

Worst:
I am sequence-minded, so my functions tend to be extremely long. I dislike taking code and moving it into a function somewhere else, telling myself that this code will only be need in this one location, so it easier to read if it's all in sequence.
I'm also bad for having nested if statements for miles. It's just how I think.

Re: Best and worst game-making habits (forum-game)

Posted: Sat Jan 08, 2011 11:45 pm
by ghostwriter
Best: Spending time with a pen and paper. I experience the most clarity and direction when planning out a project in my little notebook. Drafting out classes and methods with a pen makes the actual coding so much easier for me.

Worst: Having no clear goal...

Re: Best and worst game-making habits (forum-game)

Posted: Sun Jan 09, 2011 12:57 am
by Robin
Best: actually deciding on code architecture beforehand, instead of after I already started.

Worst: not writing (useful) comments, especially on code sections that are too smart for their own good.

Also, many things the rest have said. Especially nevon's and TechnoCat's are very recognisable.

Re: Best and worst game-making habits (forum-game)

Posted: Sun Jan 09, 2011 7:32 am
by Araqiel
TechnoCat summed it up for me, so I don't actually have anything to add.