spagetti code
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
-
psycopathicteen
- Posts: 3001
- Joined: Wed May 19, 2010 6:12 pm
spagetti code
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
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.
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
The way out is refactoring. Lots of refactoring.
- TmEE
- Posts: 790
- Joined: Wed Feb 13, 2008 9:10 am
- Location: Estonia, Rapla city (50 and 60Hz compatible :P)
- Contact:
Re: spagetti code
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
http://www.fileden.com/files/2008/4/21/ ... zation.png