Code Style
Style == Success
What is code style?
Code style is the idea that code should be formatted in a standardized, readable, and functional way that does not inhibit debugging or peer reviews. Another benefit of good code style (especially in object oriented programming languages) is the ability to code to be easily expandable and added to.
Reasons for code styles:
As the code for your robots become more complicated, you will spend as much reading code as you do writing it. This is especially true if you have several programmers on your team, all writing code for your robots.
This is why having good code style for your robots is important. Being able to easily understand and read the code makes it easier to iterate and make your code better. Otherwise, you'll spend lots of time figuring out what your teammates and your past-self had written.
Here are a couple examples:
While both of these pieces of code do effectively the same thing, the inconsistency and lack of proper spacing makes reading the bad code much more difficult.
Rules of code standards:
There are many different code style standards, and the specific one you use doesn't mater so much as you adhere to the following principles:
Your code style is consistent across your project(s)
All members of the team understand and cooperatively enforce the standards.
The style should not inhibit the functionality of the code.
Appendix: Professional Code Style-Guides
These are reference style guides that exhibit the traits mentioned above.
Teams Contributed to this Article:
BLRS (Purdue SIGBots)
Last updated