Go to Post To me, as a student, it doesn't really matter how old the RoboCoach is. My only concern is that they don't get ape-crazy when the game starts. - AZNkommander [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #13   Spotlight this post!  
Unread 01-26-2011, 02:44 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,069
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Bad Programming Practices

I subscribe to the philosophy that there is no single way to write good code - it all depends on how it will be used, re-used, modified, etc. Writing code for an F-22 is fundamentally different than writing code for a FIRST robot.

When writing code for FRC, I put tremendous emphasis on techniques that enable very quick code changes with a minimum of potential for new mistakes. In between two matches, if I need to disable a mechanism or alter autonomous mode, etc., I want to be able to get in there, find the part I care about, and have tools in place that will prevent me from doing something foolish.

To this end...

Giving good, informative names to all classes, methods, and variables goes a long way towards making code self-documenting.

Bad:
double Gyro.get();

Better:
double Gyro.getAngle();

Better yet:
double Gyro.getHeadingInDegrees;

When you read code written in this way, you don't need nearly as many comments to explain what you are doing, and it becomes quite obvious when you make a mistake. (Obviously, there's a fine line between being descriptive and re-writing the entire function in its name)

On top of that, I always name variables according to scope...

m_memberVariable (starts with m_ to indicate it is a member of a class)
k_someConstant (starts with k_ to indicate it is a constant)
l_someLocalVariable (starts with l_ to indicate it is local in scope to a given block)
g_someGlobal (starts with g_ to indicate it is a global variable)
a_someArgument (starts with a_ to indicate it is an argument to the current method)

There are likewise certain design patterns I like a lot, and others that I eschew in FIRST simply because they are less intuitive or compact.
Reply With Quote
 


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


All times are GMT -5. The time now is 08:35 AM.

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