Programmers nearly always tell you that your style sucks.

By 8 nic on February 07, 2008


if (x < foo (y, z))
haha = bar[4] + 5;
else
{
while (z)
{
haha += foo (z, z);
z--;
}
return ++x + bar ();
}

Embed Claim Make a related claim

Discussion (14)

http://www.tapsellferrier.co.uk/nicferrier/

8 nic who agreed, says

The above is GNU style which I always found to be an excellent style guide:

http://www.gnu.org/prep/standards/standards.html

Make a related claim 7 months ago (link)
http://www.tapsellferrier.co.uk/nicferrier/

8 nic who agreed, says

Heh. No, quite right Sir! You have me!

Ha Ha Ha Ha... Anyway...

It's not my style anymore. Much to my chagrin I have switched (subconsiously) to stupid BSD style:


if () {
;
}
else {
while () {
}
}

yuk. My style sucks.

Make a related claim 7 months ago (link)
http://marphod.livejournal.com/

3 Marphod who agreed, says

I prefer a GNU-like style (but without extra spaces for the braces-on-their-own-line -- leave them at the same level as the parent block)

My style complaints about that code have nothing to do with tabs, though, and everything to do with naming, using a while with a non-boolean condition, and doing a PRE-INCREMENT IN THE F*CKING RETURN STATEMENT. (Oh, and spaces between the function and its parameter list. foo( bar ) ties the parameter list to the function name in a much stronger manner than foo (bar) ).

http://www.tapsellferrier.co.uk/nicferrier/

8 nic who agreed, says

Your style is called Stroutstrup, after Bjarne.

I personally don't see anything wrong with either the pre-inc or the while test.

What do you think is wrong with them?

Make a related claim 7 months ago (link)
http://darch.myopenid.com/

6 D'Archangel who agreed, says

Unless x is static, "++x" is terrible. If it *is* static, "x" is a terrible name. Incrementing implies there's a reason you're assigning to x, leading to no end of reader confusion when they try to figure out why you chose not simply to add 1 to x. By application of your own dictum, this is a failure.

The while test is a common enough C idiom I'd let it slide[1], though it once again fails at clearly communicating your intent.

D'A

[1]: Here, "let is slide" means "do it that way myself".

Make a related claim 7 months ago (link)
http://marphod.livejournal.com/

3 Marphod who agreed, says

Consider if bar is a functor, to which x is a pre-bound argument. The return result is dependent upon the order of evaluation of the terms on return line.

Is that well specified? Do you remember the order?
--
Ignoring that specific case, I'm very much of the opinions that return statements should not have ambiguous side effects. (Is x a class member or a reference parameter? If so, increment it first and then do the line. If not, just do a +1 or a x.Increment() ).

For the while statement, its simply a personal preference.

Make a related claim 7 months ago (link)
http://darch.myopenid.com/

6 D'Archangel who agreed, says

The functor objection is pretty.

D'A

Make a related claim 7 months ago (link)
http://darch.myopenid.com/

6 D'Archangel who agreed, says

Actually, now that I think more about it, I'm unclear what you mean by the combination of "functor" with "pre-bound argument". Explain, please?

D'A

Make a related claim 7 months ago (link)
http://marphod.livejournal.com/

3 Marphod who agreed, says

std::tr1::bind()

You create a functor with an arbitrary number of parameters, and can specify an object, held by reference, to be the nth parameter for that functor.

Make a related claim 7 months ago (link)
http://www.tapsellferrier.co.uk/nicferrier/

8 nic who agreed, says

Ermm... the above code is C. You don't think the GNU project would put C++ in a style guide?? Goodness, how quaint.

Make a related claim 7 months ago (link)
http://fixedd.com/

4 fiXedd who agreed, says

@nic: Its "Stroustrup", without that first "t".

Make a related claim 7 months ago (link)
http://www.tapsellferrier.co.uk/nicferrier/

8 nic who agreed, says

@fiXedd thanks. If you could just crawl through jyte and correct all my other misspellings that would be great.

Make a related claim 7 months ago (link)
http://fixedd.com/

4 fiXedd who agreed, says

I'll get right on that :)

Make a related claim 7 months ago (link)
http://marphod.livejournal.com/

3 Marphod who agreed, says

You can do fuctors in c, with pre-bound variables. Especially since references ( Foo &foo ) is C (as of C99).

So are namespaces

It is just easier to refer D'arch to the C++ code, than to write functors by hand.

Make a related claim 7 months ago (link)
Sign in in to leave a comment.