Thread: CodeProblem
View Single Post
  #6   Spotlight this post!  
Unread 16-02-2015, 00:39
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,679
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: CodeProblem

Quote:
Originally Posted by legts View Post
I did not notice that before, thanks for pointing that out!
This is one of the important reasons to follow programming style conventions - that is, make your code look like programmers expect. In this case, the usual convention for objects is that the commas are only used if they are not being set. It's also common to keep columns aligned as you go down parallel code; this is why code is traditionally displayed in a fixed-width font. The usual style conventions would look like:
Code:
Button button1  = new JoystickButton(joystick,  1);
Button button2  = new JoystickButton(joystick,  2);
Button button3  = new JoystickButton(joystick,  3);
Button button4  = new JoystickButton(joystick,  4);
Button button5  = new JoystickButton(joystick,  5);
Button button6  = new JoystickButton(joystick,  6);
Button button7  = new JoystickButton(joystick,  7);
Button button8  = new JoystickButton(joystick,  8);
Button button9  = new JoystickButton(joystick,  9);
Button button10 = new JoystickButton(joystick, 10);
Button button11 = new JoystickButton(joystick, 11);
Following programming style conventions is nearly as important as following wiring color code conventions, and for exactly the same reason -- so that the guy (or gal) who comes behind you can easily figure out what you did. So far, it's not the law, or even in the FRC rules, but maybe it should be. Or maybe not -- do we really want code inspectors?
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.