|
Re: Bad Programming Practices
I go back to mine during the day, clean it up and add additional comments where necessary. I also try to comment as I go, so that when I go back and look at the mess I made during a flurry of lunchtime coding I can remember what I was trying to accomplish. You'd be surprised how much that helps you figure out why it isn't working when it actually gets uploaded to the bot.
Another good practice is good variable names. Mine get clear, descriptive names like spinGyro and tiltGyro, instead of something cryptic like m_gyroA1 (my gyro on analog port one? And does that one tell me if I'm turning or tipping over?) The FRC classes are really bad about that; I mean, who came up with the idea that the top line of the LCD should be named kMain6, instead of lcdLine1? Took me a lot of test messages to figure out which line was which (kMain6 is the top line, then they are kUser2 through kUser6 going down.)
I try to be aware that next year they might not have me to help them, but if the code is clear and well commented they won't have to start from scratch. There's a composition book of notes, diagrams, and explanations to go with it as well. Maybe I can get one of my students to type that up some day into something a little more legible.
|