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.
Best and worst game-making habits (forum-game)
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Best and worst game-making habits (forum-game)
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: Best and worst game-making habits (forum-game)
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.
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.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Best and worst game-making habits (forum-game)
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.
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.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Best and worst game-making habits (forum-game)
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.
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)
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
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
- ishkabible
- Party member
- Posts: 241
- Joined: Sat Oct 23, 2010 7:34 pm
- Location: Kansas USA
Re: Best and worst game-making habits (forum-game)
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.
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.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Best and worst game-making habits (forum-game)
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.
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.
Kurosuke needs beta testers
- ghostwriter
- Prole
- Posts: 38
- Joined: Sat Dec 11, 2010 11:08 pm
Re: Best and worst game-making habits (forum-game)
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...
Worst: Having no clear goal...
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Best and worst game-making habits (forum-game)
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.
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.
Help us help you: attach a .love.
Re: Best and worst game-making habits (forum-game)
TechnoCat summed it up for me, so I don't actually have anything to add.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests