Jump to content
  • Advertisement
Sign in to follow this  
sheep19

Code mess

This topic is 3448 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
I see a hidden question:
"Who is bored enough to read my code and figure out what's wrong with it, without me giving you the error message I got/info on the bug I have, and without you being able to compile and run it 'cause only the main function is there."

Anyways, from a quick glance at the code it looks like a pong tutorial or something...

Share this post


Link to post
Share on other sites
sorry,forgot the question.as you can see, it's a mess. The main loop is huge. How can i avoid tis from happening next time?

Share this post


Link to post
Share on other sites
Read up on the Extract Method refactoring. Splitting that code out into several functions will help keep it much more manageable, and eliminate some nasty hacks like the goto start; line.

Share this post


Link to post
Share on other sites
Some key points on refactoring:

Many comments like "// handle events" and "// calculate..." are highly suggestive of things to extract into new functions.

Occasions where you type the same, or similar, piece of code more than once are candidates to refactor into a function, variable or constant.

Seemingly arbitrary numeric constants, like 10, 1.5 and 5 should be replaced with named constants.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!