Any comments - do so in this thread

Just so that it's kept in people's minds.Minutes wrote:=== 2d. Coding - Evaluate and accept the coding standard ===
DominionSpy suggests that interfaces should have a prefixed I and classes a prefixed C, to avoid confusion between class names and method names. m and g prefixes should be followed by an underscore to help clarify things.
i'll try to write down what i would consider an ideal coding standard and post it here hopefully in the next couple of days...Hyronymus wrote:It was ChrisCF who pulled it of the net, I already deleted the crap intro to it. That doesn't mean you shouldn't consider ditching it all along if there's really no ground for sticking with the current one.
Code: Select all
type __name
Code: Select all
type iterName
Code: Select all
vertexSomethingSomethingElse
That is a very good point.uzurpator wrote:Other stuff can be handled by extensive commenting (And I mean extensive - each damn loop should have a description, each algorithm should get a detailed description). Petty discussions about class or method naming are imho irrelevant.
Code: Select all
+------------Oo.------+
| Transport Empire -> |
+---------------------+
Yes! There should be no room for misunderstanding about what a function does/takes. It must be heavily commented, every parameter must be documented as to what it should actually contain, what it is used for...Hellfire wrote:That is a very good point.uzurpator wrote:Other stuff can be handled by extensive commenting (And I mean extensive - each damn loop should have a description, each algorithm should get a detailed description). Petty discussions about class or method naming are imho irrelevant.
Also, each and every method and member variable of a class should have a description. Methods should also explain what their parameters "do"
Peer review is a good way to ensure the readability of the code. We want everybody to be able to read/understand/etc. the code, so if only the person who wrote it can read it, it is useless. We have to have some peer review in there, although we still do need a fairly rigid standard.uzurpator wrote:Then maybe we should - instead of making a stiff coding standard (altho SOME standard will have to be introduced) use a simple peer review?
Simply once I finish, say, Generator.cpp and Generator.h i give it to one of the other coders to review - once they understand what it does - it gets accepted.
Code: Select all
for (int x=0;x<100;x++)
for (int y=0;y<100;y++)
{
}
Code: Select all
for (int x=0;x<100;x++)
{
cout << "lol\n";
for (int y=0;y<100;y++)
{
}
}
Code: Select all
tags) to emphasize the indentation rules you suggest. ~Hellfire @ 2005-10-10 1507 GMT[/color]
Is it just me, or does this not create a needlessly large amount of file clutter? Why would we not use one-class-per-file as has been the standard with every other C++ project I have worked with? That would be just as organised, and would significantly cut back on file clutter.uzurpator wrote:
The rule is - each method has its own source file.
Naming goes as follows:
class definition is always
TEclass.h
method implementations are
TEclass_methodx.cpp
constructor and destructor of a class are in
TEclass.cpp
method parameter structures are in
TEclass_methodx.cpp
Ferinstance we have a class 'F00BAR' with methods 'dostuff1', 'domorestuff', 'dorestofthestuff'
The files for these would look like this
TEF00BAR.h //definition of the class
TEF00BAR.cpp //constructor(s) and destructor
TEF00BAR_dostuff1.h
TEF00BAR_dostuff1.cpp
TEF00BAR_domorestuff.h
TEF00BAR_domorestuff.cpp
TEF00BAR_dorestofthestuff.h
TEF00BAR_dorestofthestuff.cpp
Note - each class has its own place in the class tree - and this place is
represented by the fact that the sources will be placed in a directory
named the same as the class inside. The directory tree will mimic the class
diagram.
It would make things easier, yes. I have never seen it used anywhere else before, but in something like this is seems like a Good Idea(tm). However, the header _should_ be a single file, as most of them are simply going to be one liners. It would be stupid to have a seperate header for each, and would make working out what is in each class incredibly difficult.DominionSpy wrote:I don't think this affects the final exe size.
It's an interesting concept that I've not seen before, but as you say it certainly could make our lives a little easier.
I'm not sure about the separate header files for each method though. I think it would be more useful to have a single header file for each class. The separate ones would only have one line in and a single one could also act as an index for reference.
..which makes for one more directory level you have to traverse when looking for the source file you need to work with.uzurpator wrote:not quite - each class will have its own directory where its sources will be kept.
Most text editors have find features for exactly this reason.uzurpator wrote:
And having each method in a seperate file will make it easier to navigate - otherwise the sources will get needlessly long, and I really hate when i have to scroll several screens to search for something.
..however, there will be code repeated throughout every source file (thinking of header files, primarily); then there is a lot more code (from the perspective of the compiler) to work through, so this approach would result in longer compilation times, no? EDIT: in either case, you have the same amount of method code to compile, and whether or not that code is broken down into individual files or lumped together in one big file will itself make no difference in compilation time.uzurpator wrote: Also - it will speed up compilation - since only relatively small sources will be compiled.
...in the file of the associated class, of course.uzurpator wrote: EDIT: and I don't need to know where you have put your methods.
I agree with this - use inline methods wherever possible (i.e. under these circumstances) and our code efficiency will jump.uzurpator wrote: Altho I can think of an exception here - if you use INLINE methods that are used just by one method then they can be defined in the same file as the method that calls them.
You know - if you have some mundane piece of code used in 20 places it is better to have an inline instead of calling for the method. Also - inlines would be always private and could would not use structures for parameters and results.
Untrue - any recent version control software (CVS, SVN) will merge changes as described above if they are made at the same time to the same file assuming the two changes are not diametrically opposed, which, by the description of editing two different methods, is not going to happen in the circumstances you describe.uzurpator wrote:There is a reason for a header file for each method.
If person A wants to do work on class.method A and person B wants to work on class.method B - then with seperate files they just take the source and the header and once they finish - just upload new versions, while with a grouped headers the main file needs to be updated by hand on each new submission. Likewise with methods.
Speaking of CVS, Subversion, etc., I really think we should use Subversion, as it is so much more flexible, and was designed to be an improved CVS, and that it has been. I only used CVS here for a few weeks, then I gave up on it and moved to Subversion. There is no reason not to use Subversion, as large projects (such as Apache) now use SVN. OpenTTD uses SVN, and I don't believe they have problems with it.Grunt wrote:Untrue - any recent version control software (CVS, SVN) will merge changes as described above if they are made at the same time to the same file assuming the two changes are not diametrically opposed, which, by the description of editing two different methods, is not going to happen in the circumstances you describe.uzurpator wrote:There is a reason for a header file for each method.
If person A wants to do work on class.method A and person B wants to work on class.method B - then with seperate files they just take the source and the header and once they finish - just upload new versions, while with a grouped headers the main file needs to be updated by hand on each new submission. Likewise with methods.
Users browsing this forum: No registered users and 4 guests