


/*
 * A sample source file for the code formatter preview
 */
#include <math.h>
class Point
{
    public:
        Point(double xc, double yc) :
            x(xc), y(yc)
        {
        }
        double distance(const Point& other) const;
        double x;
        double y;
};
double Point::distance(const Point& other) const
{
    double dx = x - other.x;
    double dy = y - other.y;
    return sqrt(dx * dx + dy * dy);
}


tempIterator = currentThreadReferenceCount++;

    return (string) "Protect the creature named " + creatureName + ".";
    return std::string("Protect the creature named ") + creatureName + ".";
Goal::Goal(std::string nName, std::string nArguments)
{
    name = nName;
    arguments = nArguments;
}Goal::Goal(const std::string& nName, const std::string& nArguments)
{
    name = nName;
    arguments = nArguments;
}
oln {l Wrote}:
- unsigned int - should be enough to just write unsigned (or is there any reason not to that I don't know of?)
unsigned int foo;
unsigned foo;

StefanP.MUC {l Wrote}:I stopped working on the for loop optimizations currently (moving calls out of the condition), because for example the creature routine is a 1000+ line block with like 20-30 nested loops. It get's really nasty to keep the overview and not break something...
 that screams so much for refactoring
 that screams so much for refactoring  When I write Java I never have methods that are more than a couple of screens of code, when it is worst
 When I write Java I never have methods that are more than a couple of screens of code, when it is worst  Of course they can be big at some point, but when I find myself scrolling the screen to much I know it is time to refactor the code
 Of course they can be big at some point, but when I find myself scrolling the screen to much I know it is time to refactor the code 


unsigned int foo
for()
{
    for()
    {
        for(){}
    }
}
for(){}
for()
{
    for(){}
}
//this is going on that way...

StefanP.MUC {l Wrote}:You mean this ones: /* */ ?
Most comments are multiline anyway (escpecially if we use doxygen they get long), they are easier to extend, because you don't need to add the // by hand on every line. And the rest can be this way to, just out of consistency.
And a personal reason on my site: I don't like the double slashes (//) in code, it doesn't look nice when there are hundreds of lines starting with "//", IMHO. They are good on short single lines in example code, yes, but in bigger projects I prefer consistency.
If there's a reason to use mixed comments or only the double slashes, we can drop this point from the guidelines, of course, or make it less strict.
someReallyComplicatedEquation_1 // this produced theUniverse
someReallyComplicatedEquation_2 // this allowed theUniverse to expand
someReallyComplicatedEquation_2 // This set the return value of theUniverse to 42
/* This next section of code contains someReallyComplicatedEquation_s
that define theUnivers, its behaviour and its return value
DO NOT CHANGE!! */
//  This next section of code contains someReallyComplicatedEquation_s
// that define, theUniverse, its behaviour and its return value
// DO NOT CHANGE!!
someReallyComplicatedEquation_1 /* this produced theUniverse */
someReallyComplicatedEquation_2 /* this allowed theUniverse to expand */
someReallyComplicatedEquation_2 /* This set the return value of theUniverse to 42 */


StefanP.MUC {l Wrote}:Ok, I dropped the comment part of the guidelines.


//BAD
int member;
void setMember(int member)
{
    this->member = member;
}
//GOOD
int member;
void setMember(int newMember)
{
    member = newMember;
}
Users browsing this forum: No registered users and 1 guest