Early Programming Mistakes

Chieftess

Moderator
Retired Moderator
Joined
Feb 10, 2002
Messages
24,160
Location
Baltimore
For all of the programmers here, what were the top mistakes (in order) you used to make when just starting out with programming, or learning how to program and attempting to do a project?

Back when I made some games (or tried to), these were the mistakes I used to make:

1 - Concentrating too much on the presentation: Or, in this case, graphics. I wound up like this guy, the one that spent 6 months creating a prototype. Basically, I would try to do too much at once on the screen. I wasn't content with dummy-text based data at the time. I thought I'd have to redo the entire program if I were to do that.

2 - Hardcoding: Granted, it might not be bad in itself all of the time, but... when you start coding like this: (keep in mind, this one relates to Turbo Pascal, which is based on an actual code example)

Code:
town1() begin ... end;
town2() begin ... end;
town3() begin ... end;
drawmap() ... (I would actually have every tile drawn pixel by pixel in this procedure)

GameLoop
 drawmap();
 CaptureMapMovement();
 If (x=3) and (y=7) then /*(this was my "event" trigger code)*/
 begin
 town2();
 end;
.
.
.

and it's all in one file, things can get pretty hairy. Sure, it's possible to make a game like this, but debugging it, or adding stuff to it just isn't going to be pretty.

3 - No gameplan: I never had things analyzed like, "What does the player data look like? What does the item data look like? What does the tile data look like?", and so on. I didn't even have files to be included that were seperated into things like graphics, and classes for other game objects.

4 - Staying on one piece of code/feature for too long: This was pretty much evident in my trying to solve the graphics presentation problem for years on end while trying to program a game at the same time. I attribute that to my Polish stubborness gene I probably inherited. :)

5 - Arrays: This was mostly with C++, especially after coming from Turbo Pascal. TP would start at 1, and if the array was initialized to have 10 items, that's the last number it would be. (i.e., int somearray[1..10]; would be somearray[1] to somearray[10].) So, naturally, after making the switch to C++, I would write:

int i[10];

then think, "Ok, that's 1-10. No, wait, C++ starts at 0. That's 0-10!".

Now, depending on the compilier, it would either spit out garbage, throw a hissy fit, or throw a general protection fault (in some cases - my friend liked causing these for some odd reason - practically the only thing she did...).

So, my code would look something like:

for(int i=0;i<=10;i++) (or, I might do i<11 just to get the 10). It took me quite awhile to break the Pascal habit of 10 being 10, and not 9.
 
It's been a long time since my "early programming" days. ;)

But I do remember a slight tendency to hardcode stuff. Especially file locations. ("But what if a user doesn't have 'C:\Windows\Temp' on his system? Your program will die right there!")

Not having a solid plan was a bit of a problem, I always wanted to jump in and code. Never mind that it wouldn't tie with any other piece, or might actually cause more problems than it solves. I still see this a lot today, as "cowboy coders" start performing maintenance on programs. ("No! Stop and think! Show me your design, and get it approved, before you write a single line of code!")
 
Padma said:
Not having a solid plan was a bit of a problem, I always wanted to jump in and code. Never mind that it wouldn't tie with any other piece, or might actually cause more problems than it solves. I still see this a lot today, as "cowboy coders" start performing maintenance on programs. ("No! Stop and think! Show me your design, and get it approved, before you write a single line of code!")

Yeah, that's exactly why I get funny looks from the people who use my program when they think it's an easy change to make (i.e., "It shouldn't take *THAT* long to re-code the single location program into a multi-user-multi-regional access program...), and I turn around and do the analysis...
 
I've been guilty of jumping in without thinking plenty of times.

Another thing I've noticed (this is not actually about myself, but about a program I'm currently attempting to debug for someone else), is the tendency for people to use too-short, undescriptive, and confusing variable names... in the program I'm trying to debug there is a variable that in the main function is called n, in another function is called i, and in yet another function is called s. A more descriptive name would be really useful in allowing me to figure out why it's there.
 
Chairman Meow said:
I've been guilty of jumping in without thinking plenty of times.

Another thing I've noticed (this is not actually about myself, but about a program I'm currently attempting to debug for someone else), is the tendency for people to use too-short, undescriptive, and confusing variable names... in the program I'm trying to debug there is a variable that in the main function is called n, in another function is called i, and in yet another function is called s. A more descriptive name would be really useful in allowing me to figure out why it's there.

Add to that the lack of comments, too. For example, when I was making a web-based program of a program we used to have in MS Access, some functions, I had no idea what they did since there weren't a whole lot of comments. (I even missed a feature because the other programmer never told me about it, and I didn't have access to it then -- which was during my internship).
 
Not that i don't make any programming mistakes anymore, but my earliest mistakes were made in Turbo Pascal.
I was taking the Figure-it-out-yourself approach back then and OOP or even structured programming were completly alien concepts to me.

So i went ahead and wrote a character generation program for a pen&paper rpg:
- All variables were declared global, as i didn't see the point behind restricting access to them. Globals are much more flexible!

- As a lazy typer, i followed adamantly a "3 letter max" naming convention.

- I disliked functions, since they forced me to scroll up and down. Scrolling down to the fuction was no problem, but scrolling up and finding the line where it was invoked was difficult. So i just copy and pasted code where ever possible, instead of writing a function.

- My "hacker" friends told me, that comments are for the weak of mind, so i made sure that my code didn't contain any.

- The complex dependencies of character generation were tackled with muli layered IF clauses. At least a dozen layers. Of course, i forgot to close brackets (Code formating? What's that?!) and after the complainer complained about it, i added them at the wrong places more often than not.

Needless to say, the resulting programm did all kind of funky and unexpected stuff, but it didn't help in character generation in any way. :D
 
Speaking of hardcoding of things... check out this code I found. Check out the code to give the player an item, and the main game loop. Yuck!

Sure, it does it, but I wouldn't like to debug that thing!
 
Chieftess said:
Speaking of hardcoding of things... check out this code I found. Check out the code to give the player an item, and the main game loop. Yuck!

Sure, it does it, but I wouldn't like to debug that thing!
Why are there goto statements in cpp? Not that it's so wrong, but couldn't logic be done without having goto statements?

Why are the functions lo big? I mean, 300+ lines? Even if it costs you branches in runtime, breaking those functions down where you functions within functions actually makes reading and maintaining the code easier. heck, make em inline if you want. But that code has more comments then I would originally put (until the project is done and I finally get time to comment).

I've made too many mistakes to remember them all. I can't remember what I've learned unless I have something to contrast with. I can't be bothered that hard to think about this :p
 
kingjoshi said:
Why are there goto statements in cpp?

:lol: I think I must've missed those looking at that code.

If it were me, I'd do the following:

1 - Break up that code into managable functions.
Currently, it's:
GrabItem - 417 lines of switch case madness! :eek:
Update - 452 lines of update madness! (Update what???)
PlayGame - 359 lines of code...
Averaging a little over 400 lines of code per function for the major functions.
2 - Create an event class to handle all of the game actions. That'll clear about half the code right there.
3 - Do something about all those if statements. There's just too many, and most seem to be relating to events, too -- especially the grabItem function. There's lots of similar function calls (increment/decrement a value, playing a sound effect). I might have some sort of script-like file (or data) to handle that, along with the event engine.
4 - Make more meaningful variables. (t1, t2, t3, t4? sv? I could guess, but it might be wrong)
 
may main early mistakes were basically similar.

1. Hardcoding (I hardcoded everything :) )
2. switch-case madness (or even worse infinite if/else blocks)
3. I was too lazy to give my variables and methods easy to understand names: try to find out what int xyz stores after a few weeks ;)
 
I took a class on Java programming, and I have to say that I'm impressed with people who can code well. I had enough trouble avoiding stupid spelling errors, etc., without even going into why stuff would or wouldn't work.
 
My biggest mistake was learning to program by recording macros in Excel & then trying to work-out what they did. I didn't really understand about scope of variables etc (local vs global) and of course the default in VB is to have option explicit off. I remember trying to split code out into functions, and finding that they simply stopped working, without really knowing why. :ack:
 
okay, C/C++ is case sensitive. don't go "#defining False 1" somewhere and mucking around with the code just to confuse professors :p

Some guy did that and wanted me to help him with is code when it wasn't working. AHHH

I got it to work but he couldn't read his own code once it was fixed :lol:
 
<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What is this guy doing?"
Link. I've done that before.

I'm self taught on DCL and Visual Basic. A lot of the simple stuff was hard at first, and then once it became old hat, I couldn't understand what all the fuss was.

Hardcoding was a problem for me at first too. Funny thing, tho, I've never hard coded a menu, it's always been in a text file.
 
kingjoshi said:
Why are there goto statements in cpp? Not that it's so wrong, but couldn't logic be done without having goto statements?

It could, but it doesn't hurt the program any, since an if statement is just a conditional goto when it gets compiled anyway. After learning MIPS assembly, I'm constantly tempted to throw goto's everywhere.
 
History_Buff said:
It could, but it doesn't hurt the program any, since an if statement is just a conditional goto when it gets compiled anyway. After learning MIPS assembly, I'm constantly tempted to throw goto's everywhere.
goto statements can be great quick hacks. what can get hurt is the code. Spaghetti code is really difficult to manage and maintain.
 
My first and biggest programming error was taking a programming course! booo programmin!!!!
 
Back
Top Bottom