Go to Post This will be one of the nerdiest weekends in the history of the world. And I'm taking part in it! (yay!) - Dan Petrovic [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 17-12-2009, 19:35
Bigcheese Bigcheese is offline
C++0x FTW!
AKA: Michael Spencer
FRC #1771
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2008
Location: GA
Posts: 36
Bigcheese is a jewel in the roughBigcheese is a jewel in the roughBigcheese is a jewel in the roughBigcheese is a jewel in the rough
Re: Driverstation Pong!

This is quite a cool idea, although I did take a look at your code and found some issues.
  • There are quite a few places where there's no code formatting, making it very difficult to read.
  • The use of a try/catch statement for program flow is bad. There's no reason to do this. Simply use a goto statement if you want to reenter the loop.

Now, to defend the use of goto.
Using an exception is the exact same thing as a goto in this case, except that the try/catch implies something different is going on, and ignores all real exceptions because of the catch(...).

Yes, you could use some extra logic to handle exiting the double loop, but in the end, the simplest, and most readable solution is to have a label directly before the main while, and a goto on win.

Although the best solution would be to split the code up into separate functions such as.
  • Setup
  • WaitForStart
  • Update - Returns a value in {continue, player_1_won, player_2_won}

Then the problem wouldn't be there to begin with .
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
driverstation outputs agough C/C++ 3 15-02-2009 22:25
mindstorm and pong RX7-bernie General Forum 1 01-03-2007 14:54
Shooting Ping Pong Balls Jeremiah Johnson FIRST Tech Challenge 1 01-05-2006 21:20
pong mechanik Andrew Rudolph Chit-Chat 4 13-10-2004 22:44
Revive a Classic: Pong K. Skontrianos General Forum 6 21-02-2003 16:20


All times are GMT -5. The time now is 15:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi