spagetti code

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
spagetti code
by on (#97914)
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?
Re: spagetti code
by on (#97916)
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.
Re: spagetti code
by on (#97922)
The way out is refactoring. Lots of refactoring.
Re: spagetti code
by on (#97952)
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