View Single Post
  #8   Spotlight this post!  
Unread 17-11-2011, 10:29
Boydean's Avatar
Boydean Boydean is offline
The Blue Alliance
no team
Team Role: Alumni
 
Join Date: Apr 2007
Rookie Year: 2003
Location: SC
Posts: 319
Boydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant futureBoydean has a brilliant future
Send a message via AIM to Boydean
Re: How to go from simple working code to professional code

I have little experience with Labview but this subject interests me, and a lot of this advice can be applied to other areas of software development.

Echo what is being said above. Simplify. If something is too complex to explain in plain english then you need to break it down more (more SubVis).

Your code (or blocks) should be explicit as possible. Variables should state what its used for in plain english. Remember that code is read more then it is written – so take the time to actually type "map" and not something like "mp". You ain't special for naming something other people won't understand.

Functions and methods (SubVis) should state what they do in plain english. Use verbs and nouns if the function does something. Example "set_motor_speed" vs "motor_speed".

Comments. Abusive commenting is abusive to the reader. No one wants to read an entire paragraph of comments in the middle of some code. Changing focus from reading coding to interrupting comments with code is annoying. If your code is explicit enough then comments should only be used to explain why you are doing something.

Bad:
Code:
// Set motor speed to 0.5.
set_motor_speed(0.5);
Good:
Code:
// Anything greater then 0.5 will destroy our arm. Monkeys are awesome. – @brandondean Nov 17
set_motor_speed(0.5);
EDIT: Global variables are bad. Don't use them. Although, if I recall correctly with Labview this is unavoidable...I think.
__________________

Last edited by Boydean : 17-11-2011 at 10:41. Reason: ninja edit
Reply With Quote