Re: Formatting for humans or for tools?
On May 12, 4:15 pm, DeMarcus <use_my_alias_h...@hotmail.com> wrote:
Alf P. Steinbach wrote:
At the last meeting of Oslo C++ Users Group it was maintained (as I
understood it) that code like ...
SomeType someName; // =
Knurre.
SomeOtherType someOtherName; // Voff.
AThirdType aThirdName; // That=
was a good catchy melody.
Fifthum huhWhatsThat; // But =
you're too young to
remember.
NoHeresTheReal5th ohYeah; // Probably=
..
... is bad, because most any refactoring tool tool will destroy the nic=
e
line-up when you change those type names, and that it's therefore much
better & preferred to have no line-up, like ...
SomeType someName; // Knurre.
SomeOtherType someOtherName; // Voff.
AThirdType aThirdName; // That was a good catchy melody.
Fifthum huhWhatsThat; // But you're too young to remember.
NoHeresTheReal5th ohYeah; // Probably.
It seemed that everybody agreed.
Comments?
I used to go for the first one, especially for functions in header
files, but I gave up since it was too difficult to be consistent. E.g.
class SomeClass
{
public:
void doSomething();
int doSomethingElse();
std::map<std::string, MySpecialClass> destroyIndentation();
};
It would be awkward to change to
class SomeClass
{
public:
void =
doSomething();
int =
doSomethingElse();
std::map<std::string, MySpecialClass> destroyIndentation();
};
Not to mention when all wicked arguments come into play. Basically, I've
given up, and now I'm just trying to make it nice looking at the spot
without using any stringent formatting convention.
This is anyway written usually so:
class SomeClass
{
public:
typedef std::map<std::string, MySpecialClass> SpecialAtName;
public:
void doSomething();
int doSomethingElse();
SpecialAtName destroyIndentation();
};