spagetti code

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
psycopathicteen
Posts: 3001
Joined: Wed May 19, 2010 6:12 pm

spagetti code

Post by psycopathicteen »

Is there an easy way out of spagetti code? A couple years ago I had an unfinished game named "Secret Agent Insane Maniac" which I stopped developing because of spagetti code. Now "Busty Baby Blows Bots" is beginning to look like spagetti code, too. Do I have to start another project from scratch again?
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Re: spagetti code

Post by Bregalad »

I think it just takes some practice, and you should notes your errors (not programming errors, but structural errors that makes you unable to continue your own work after a pause) so you don't do them again.

Basically the only tips I could say is :
- Use variable names that make sense (this is not as easy as it sounds - I know)
- Use names that makes sense for your functions
- If you're coding in assembly, add a header in front of every function to specify what input / output parameters they use, and which "Temp" variables they use/modify/rely-on
- Don't ever copy/paste code, but use a function or a macro instead.

Maybe it would also be a good idea to re-write some parts of your code, changing variable's name and adding comments, instead of re-starting something from scratch.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: spagetti code

Post by tepples »

The way out is refactoring. Lots of refactoring.
User avatar
TmEE
Posts: 790
Joined: Wed Feb 13, 2008 9:10 am
Location: Estonia, Rapla city (50 and 60Hz compatible :P)
Contact:

Re: spagetti code

Post by TmEE »

Group all your code (i.e all VDP access goes into one group) and then give the group its own file which you'll include in the main file.
http://www.fileden.com/files/2008/4/21/ ... zation.png
Post Reply