View Single Post
  #28   Spotlight this post!  
Unread 25-07-2010, 22:34
LukeS LukeS is offline
4272 mentor, 1024 alumnus
AKA: Luke Shumaker
FRC #4272
Team Role: Mentor
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Indianapolis, IN
Posts: 60
LukeS is an unknown quantity at this point
Re: New Programming Manual

Versioning:
Our team used
projectname-yyyy.MM.dd.hh.mm (description)
The autosorting still keeps them in the right order, you get a summery of the changes, and can have multiple projects in the same directory.
Also, if we are working in the same directory as the backups, we use the version `wch' to mean the working copy. This still works, since `w' will autosort to after anything you would put in for yyyy, so it is ``more recent'' than any of your backups.

Of course, we didn't use that much this year, since we used an actual versioning system. We use Mercurial, since it seamed easiest to set up on Windows. You will need to install it separately from here (if you're using a package manager, use that instead). I've already made a post on Mercurial (http://www.chiefdelphi.com/forums/sh...d.php?t=83588).
Quote:
Originally Posted by LukeS View Post
Also, since Windows and *NIX newlines are different, Netbeans automatically does this, so you end up having to make an empty commit with the message ``convert to UNIX newlines, ignore...''
I later realized, that even though Netbeans makes you do this, Mercurial normalizes all newlines in the archive anyway, and rejects the commit as an empty commit. Also, newer versions of Netbeans do not have this problem.

In order to clone between computers with Mercurial, you need SSH. Most of the time, we would just clone to a USB drive (using above naming convention for the clone). However, especially if several developers are working at the same time, cloning is very nice. Though it we never found a `great' solution, using Cygwin to install openSSH on Windows machines seems to be the best option. Don't use the stripped down ssh-only cygwin program.

Formatting:
Brackets
While I respect your code formatting choices, every programmer I have talked to generally agree that not giving braces their own line improves readability and economy of space
Code:
if (condition) {
    ...
} else {
    ...
}
...
Although, many C programmers make an exception for functions, and give the brackets their own line. This is because it's what's in K&R C.

Tabs
Also, all of our programmers agree that it makes editing code way easier if you use tabs instead of multiple spaces. This can be adjusted in Netbeans by going to Tools/Options/Editor/Formatting. Uncheck ``Expand tabs to spaces'' and adjust the first to numbers to 4 (or, both to 8, if you prefer. I use 4 in OO languages, 8 otherwise).

Netbeans shortcuts
Also, it should probably be noted that in Netbeans, if you highlight several lines of code, you can hit <tab> to shift them to the right, and <shift>+<tab> to shift them to the left, instead of clicking the buttons.

Javadocs:
Instead of giving users a link to a web page with the WPILibJ javadocs, you should give them the location on their computer, since at competitions they probably won't have Internet, and it might change with an update.
on Windows:
%USER_ROOT%/sunspotfrcsdk/doc/javadoc/index.html
on *NIX:
$HOME/sunspotfrcsdk/doc/javadoc/index.html

Also, you should talk to them about writing javadocs for their own code, if you have a complex robot (or, at least complex code), this is a life-saver. It also makes it way easier for a new programmer to wrap his head around your code-base.

Misc:
Correction: You note that in the default code, they use `m_' for ``robot parts''. Actually they use it for anything that will likely be changed frequently (likely the `m' is for `mutable'). For example, the the active buffer in the network code in WPILibJ is m_buffer (or something like that).
Typo: in ``COOLEST THING I SAW'' (which is *very* cool), the sample code you give will not work, you use
Code:
m_ pot* instead of
m_pot*
when getting the different pots from the drive station.
Suggestion: It may be educational for programmers to peak at the WPILibJ source code. It is installed at `sunspotfrcsdk/lib/WPILibJ/' (same sunspotfrcsdk folder as the javadocs, see above)

Last edited by LukeS : 25-07-2010 at 22:42. Reason: add formatting to headers, improve readability
Reply With Quote