Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Programming Organization (http://www.chiefdelphi.com/forums/showthread.php?t=40587)

coastertux 22-11-2005 16:00

Programming Organization
 
Last year we only had 2 students programming so we both worked on the same piece of code and didn't worry too much about conventions, etc. This year it looks like we will have about 8 people on the programming team and were wondering how we can manage that many people. What types of conventions like indents, variable names, function names, constants, and comments can we require? Also, how can we divide the programming and then get it all back together into one easily?

Thanks!

Mike 22-11-2005 16:20

Re: Programming Organization
 
First off, I'd recommend setting up a CVS (Concurrent Versions System) server. Concurrent Version System - Wikipedia, the free encyclopedia

As head programmer (which I'm assuming you are), I would setup a set of standard header files. These would be included in the necessary source files, with each header file being completely independent and modular. Say you need to use PID control in a source file, you should just have to include pid.h and it should cover everything you need.

To be honest, I wouldn't worry too much about indent size/function names/etc. Have enough of a standard to make it readable, but not enough to hinder a persons programming time because they have to look up whether it's Function_Name or function_name.

With that being said, I admit to being a perfectionist. This is my current self-standard:
All brackets are placed on next line
Code:

// Good
if(foo == bar)
{
return;
}

// Bad
if(foo == bar){
return;
}

Constants are referred to in capitals, all others in lower case.
Code:

// Good
#define PI 3.14
unsigned int some_variable;

// Bad
#define pi 3.14
unsigned int SOME_vArIABLE;

Variables/Functions use underscores to replace spaces.
Code:

// Good
void Read_Encoder(void)

// Bad
void ReadEncoder(void)

Use short, clear and concise variable/function names.
Code:

// Good
unsigned int left_encoder_clicks = 0;
void Update_Encoder_Count(void)

// Bad
unsigned int amount_of_clicks_back_from_the_encoder = 0;
void Update(void)

Use double slash comments.
Code:

// Good
/* Bad */

Like I said, try to not have super-harsh standards. These are my own, and I realize that they probably are pretty strict... but they are for myself only. If I were to work with a programming team, they would be much more lax.

EDIT: I'd just like to add that I change my standards a lot... just because I'm a perfectionist like that.
The great thing about standards is there are so many to choose from.
-Anonymous

Rickertsen2 22-11-2005 17:06

Re: Programming Organization
 
Plan plan plan plan plan and plan your code before writing it. Agree on interfaces between code bits ahead of time. C is a loose and rather permissive language so it is important to agree on coding standards. A CVS is a good idea. Document the code well. Maintain change logs. Document everything where reasonable. Abstract and encapsulate where reasonable. Modular code helps with group projects. It is one thing to be able to write code that you understand. It is another to write code that can be easily modified and understood by others.

I have a guide NOT to follow: How to write unmaintainable code

Mike 22-11-2005 17:09

Re: Programming Organization
 
Quote:

Originally Posted by Rickertsen2
I have a guide NOT to follow: How to write unmaintainable code

On a somewhat-kinda-related tangent, visit TheDailyWTF and make sure not to do anything you see there :p

Timothy D. Ginn 22-11-2005 18:01

Re: Programming Organization
 
Quote:

Originally Posted by coastertux
...
This year it looks like we will have about 8 people on the programming team and were wondering how we can manage that many people. ...
Also, how can we divide the programming and then get it all back together into one easily?

Thanks!

Well, congratulations on being able to find such numbers; it seems to be rare that teams will get that many people interested in programming.

The advice given so far about using some version management system (like for example CVS or Subversion) is good (actually, it's even handy if you were the only one programming since if you're ever in a situation where you make a big oops you can revert back to a good copy).

One thing that I would like to add though, is that with such a large group I would consider it likely that there will be problems with certain members not having enough to do at times (which can spin off into a feeling of not making a valuable contribution and eventually a lack of interest in attending) none of which are good things. Be very careful about this; it's not always easy to notice and people won't always admit if they're feeling left out. Assuming your programming team does both robot and website programming it might be worth splitting into two subgroups so that people can take ownership of a particular task.

lndnny 22-11-2005 19:42

Re: Programming Organization
 
Quote:

Originally Posted by Mike
First off, I'd recommend setting up a CVS (Concurrent Versions System) server. Concurrent Version System - Wikipedia, the free encyclopedia

As head programmer (which I'm assuming you are), I would setup a set of standard header files. These would be included in the necessary source files, with each header file being completely independent and modular. Say you need to use PID control in a source file, you should just have to include pid.h and it should cover everything you need.

To be honest, I wouldn't worry too much about indent size/function names/etc. Have enough of a standard to make it readable, but not enough to hinder a persons programming time because they have to look up whether it's Function_Name or function_name.

With that being said, I admit to being a perfectionist. This is my current self-standard:
All brackets are placed on next line
Code:

// Good
if(foo == bar)
{
return;
}

// Bad
if(foo == bar){
return;
}

Constants are referred to in capitals, all others in lower case.
Code:

// Good
#define PI 3.14
unsigned int some_variable;

// Bad
#define pi 3.14
unsigned int SOME_vArIABLE;

Variables/Functions use underscores to replace spaces.
Code:

// Good
void Read_Encoder(void)

// Bad
void ReadEncoder(void)

Use short, clear and concise variable/function names.
Code:

// Good
unsigned int left_encoder_clicks = 0;
void Update_Encoder_Count(void)

// Bad
unsigned int amount_of_clicks_back_from_the_encoder = 0;
void Update(void)

Use double slash comments.
Code:

// Good
/* Bad */

Like I said, try to not have super-harsh standards. These are my own, and I realize that they probably are pretty strict... but they are for myself only. If I were to work with a programming team, they would be much more lax.

EDIT: I'd just like to add that I change my standards a lot... just because I'm a perfectionist like that.
The great thing about standards is there are so many to choose from.
-Anonymous


Code:

// Good
if(foo == bar)
{
    return;
}

// Bad
if(foo == bar){
    return;
}

you should indent stuff between brackets

Cuog 22-11-2005 19:55

Re: Programming Organization
 
It will also depend on what people are anal retentive about, I for example dont really care what your variable names are as long as i can easiy figure out what they mean:

useless_person //good
p //bad

But I cannot stand bad spacing/indenting, When i did team projects in my programming class last year i would go through and fix all the spacing before starting

Also everyone in your team willing to program you should teach them OOP(at least the basics) so that they are not lost in all these crazy files and their interaction.

Our team also has a small programming base and we like it that way:
2 people now three that i Switched from JAVA and C# to PIC "C"

coastertux 22-11-2005 20:40

Re: Programming Organization
 
How would I set up a SVN/Subversion?

Rickertsen2 22-11-2005 23:46

Re: Programming Organization
 
8 people is quite alot for such a small project. What is the experience level of each member like?

TimCraig 23-11-2005 00:51

Re: Programming Organization
 
The primary purpose of coding standards is to make the source code easy to read. While the compiler may not care, source code MUST be readable by humans. If you're used to the standard in place, sometimes you can glance at a piece of code and know there's a problem because it just doesn't look "right". When the body of code is uniform, it's just easier to read and understand. This may not seem all that important on small projects like the control code for a FIRST robot, but for real projects of half a million lines of code, it becomes very important for productivity. On projects like that people come and go and it's important that things be clear and concise.

FWIW, the example programs that come with Microsoft's Visual Studio are NOT good examples of how to program in a production environment. In fact, most of the examples roaming around the web are pure crap. Unfortunately, this obervation probably also applies to the majority of production code in acutal software products.

Dave Scheck 23-11-2005 10:51

Re: Programming Organization
 
Quote:

Originally Posted by Mike
Use double slash comments.
Code:

// Good
/* Bad */


Please not that C compilers are not required to support the double slash style comment. I would try to stay with the language specific comments for portability. If IFI were to change the RC and we needed a new compiler, there would be a chance that it wouldn't support the double slashes. In that case, you would be causing yourself to do extra work in porting the comments.

We actually just ran into this exact issue when teaching our software students. We designed labs and homework using the mcc18 compiler and mistakenly had double slash comments in some places. When we gave them the assignments, they were to use a gcc compiler. We found out quickly that gcc doesn't support the double slash and we had to go back and fix it.

Mike 23-11-2005 13:35

Re: Programming Organization
 
Quote:

Originally Posted by Dave Scheck
We found out quickly that gcc doesn't support the double slash and we had to go back and fix it.

Hmm, that's weird... I use avr-gcc (a gcc port for the AVR line of microcontrollers) and it allows the double-slash style.

But like I said, that is my personal standard.

Ryan M. 23-11-2005 15:53

Re: Programming Organization
 
Quote:

Originally Posted by Dave Scheck
We found out quickly that gcc doesn't support the double slash and we had to go back and fix it.

Really? Hm... works fine here.

And as a side note, while I agree with Dave, '//' is supported by the MCC18 compiler.

WizardOfAz 23-11-2005 17:01

Re: Programming Organization
 
I would second the recommendation by Mike Sorrenti ealier in this thread about using CVS to share code among the programmers and manage changes. An environment that integrates CVS very nicely is Eclipse. See this thread (http://www.chiefdelphi.com/forums/sh...ad.php?t=37736) for information about using Eclipse for FRC development. We've switched to it, and will never go back. You basically trade Eclipse for MPLAB, and although you lose the simulation capability, it is not all that useful for FRC projects anyway. In exchange, you get CVS, a C-aware editor, and experience with an IDE environment that is the standard in many commercial development shops.

It will take some learning and effort to get the eclipse and CVS environment set up, and for you to understand how to steer it, so if you're going to do it, start now so you're up to speed before competition season. Pretty good information is available in the CD thread mentioned above, and a few others you can find by searching for Eclipse. I am willing to help via PM or even phone, as long as the level doesn't get overwhelming.

BTW - Eclipse is open source and free, so there are no costs or difficult licensing issues.

If you want CVS but not Eclipse, maybe TortoiseCVS would be the way to go. It's also free and open-source.

You can get a free CVS account from sourceforge.net. By using it, you are not only getting change control, sharing among your team members, and backup, but you're sharing with other FIRST teams - in true FIRST spirit!

You can see all of our code there, in sourceforge project "crush1011".

Bill Bennett

Dave Scheck 23-11-2005 17:01

Re: Programming Organization
 
Quote:

Originally Posted by Mike
Hmm, that's weird... I use avr-gcc (a gcc port for the AVR line of microcontrollers) and it allows the double-slash style.

Quote:

Originally Posted by Ryan M.
Really? Hm... works fine here.

The gcc that failed was version 3.4.2 for ming. I tried it with gcc 3.4.4 for Cygwin and it works fine.

I guess this proves my point that it's best to use the /**/ style for portability ;)


All times are GMT -5. The time now is 13:02.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi