473,698 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The world's evilest code formatting style

C++ers:

Feast your eyes:

void Home::
inherits (IdentifierPtr const& id)
{
...
}

For those of you who haven't figured it out yet, that's the method
Home::inherits( ).

I suppose the theory is that Home:: is an enclosing type, so it should
pretend to wrap the method, like a namespace.

Now that's not evil just because it's so contrary to common styles and hence
hard to read. It's totally evil when it makes Home::inherits impossible to
search for. Searching, for big projects, is kind'a important!

Can anyone think of an eviler style, seen in published code? ;-)

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jun 4 '06 #1
93 3856

Phlip wrote:
Can anyone think of an eviler style, seen in published code? ;-)


Yes.

http://code.axter.com/dynamic_2d_array.h

Google groups is likely to do wonders here...all of the following is on
4 concurrent lines:

dynamic_2d_arra y(size_t row, size_t col):m_row(row) ,m_col(col),
m_data((row!=0& &col!=0)?new T[row*col]:NULL){}

dynamic_2d_arra y(const
dynamic_2d_arra y&src):m_row(sr c.m_row),m_col( src.m_col),
m_data((src.m_r ow!=0&&src.m_co l!=0)?new T[src.m_row*src.m _col]:NULL){

for(size_t r=0;r<m_row;++r )for(size_t c=0;c<m_col;++c ) (*this)[r][c]
= src[r][c];

}

Guess he didn't want to waste any space or enter characters.

Jun 4 '06 #2
Although that sucks... its not as bad as people who "right brace"... so
called "right bracers"... ie:

void Whatever() {
for (int i = 0; i < 100; i++) {
printf("whateve r\n");
}
}

Thats just dumb beyond dumb. A guy I worked with actually said he does it
like that because "putting it on the next line just wastes a line". I'm
thinking the fact that he has a brain is just a waste of precious brain
cells that others could better utilize.
"Phlip" <ph******@yahoo .com> wrote in message
news:_G******** **********@news svr11.news.prod igy.com...
C++ers:

Feast your eyes:

void Home::
inherits (IdentifierPtr const& id)
{
...
}

For those of you who haven't figured it out yet, that's the method
Home::inherits( ).

I suppose the theory is that Home:: is an enclosing type, so it should
pretend to wrap the method, like a namespace.

Now that's not evil just because it's so contrary to common styles and
hence hard to read. It's totally evil when it makes Home::inherits
impossible to search for. Searching, for big projects, is kind'a
important!

Can anyone think of an eviler style, seen in published code? ;-)

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!

Jun 4 '06 #3
Nobody wrote:
Although that sucks... its not as bad as people who "right brace"... so
called "right bracers"... ie:

void Whatever() {
Oh, my. I was this -><- close to putting in a disclaimer "don't bring up
braces", but I figured that nobody ... would.

Everyone complains about braces, and once you are over it, you are over it,
and you can read, edit, and refactor, regardless of whatever silly bracing
convention is used.

I suppose putting most (but not all) braces in the first column might be an
exception there...

Noah Roberts cited:
dynamic_2d_arra y(size_t row, size_t col):m_row(row) ,m_col(col),
m_data((row!=0& &col!=0)?new T[row*col]:NULL){}


Now now - you may as well bust on Dinkumware's old STL style. That gets
worse when your remote colleague writes unmaintainable BASIC and crams lines
full of run-on statements with 2-letter variables "because I can get more on
the screen like that".

Let's narrow the question to a style that is A> hallowable in a style guide,
and B> a failed attempt at clarity, not a successful attempt at obscurity.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jun 4 '06 #4
Nobody wrote:
Although that sucks... its not as bad as people who "right brace"... so
called "right bracers"... ie:

void Whatever() {
for (int i = 0; i < 100; i++) {
printf("whateve r\n");
}
}

Thats just dumb beyond dumb.
Dear top-poster,

care to provide a reason ...
A guy I worked with actually said he does it
like that because "putting it on the next line just wastes a line". I'm
thinking the fact that he has a brain is just a waste of precious brain
cells that others could better utilize.


.... instead of jumping to insults right away?
[mindlessly copied original post redacted]
Best

Kai-Uwe Bux
Jun 4 '06 #5
Kai-Uwe Bux wrote:
void Whatever() {
for (int i = 0; i < 100; i++) {
printf("whateve r\n");
}
}

Thats just dumb beyond dumb.
care to provide a reason ...
Because our last best hope for clarity among nested blocks is the ability to
see { in the same column as }.

(The goal "don't write too many lines in a block" also applies. And some
namespace situations make that impossible, too...)
[mindlessly copied original post redacted]


Redaction connotes emmending, not snipping. Try "elided". ;-)

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jun 4 '06 #6
Phlip wrote:
C++ers:

Feast your eyes:

void Home::
inherits (IdentifierPtr const& id)
{
...
}

For those of you who haven't figured it out yet, that's the method
Home::inherits( ).

I suppose the theory is that Home:: is an enclosing type, so it should
pretend to wrap the method, like a namespace.

Now that's not evil just because it's so contrary to common styles and
hence hard to read. It's totally evil when it makes Home::inherits
impossible to search for. Searching, for big projects, is kind'a
important!


I see the importance of grepability for code. However, there will be many
contexts where it does not read Home::inherits but just inherits anyway.

Full disclosure: virtually all of my code is templated which means I ditched
the distinction of header and implementation files since implementation
files would almost always be empty anyway (given that my compiler does not
suport export). Consequently, I also ditched declaration vs. definition,
i.e., everything is defined in place so that the class::method() form just
does not occur in the code. I never found a drawback with regard to
grepability or readability of code.
Best

Kai-Uwe Bux
Jun 4 '06 #7
Phlip wrote:
Kai-Uwe Bux wrote:
void Whatever() {
for (int i = 0; i < 100; i++) {
printf("whateve r\n");
}
}

Thats just dumb beyond dumb.
care to provide a reason ...


Because our last best hope for clarity among nested blocks is the ability
to see { in the same column as }.


I guess whether that poses a problem depends heavily on what you are used
to. I never found any difficulty with right-bracing in regard of clarity.
But then again, my blocks are not that deeply nested anyway.
(The goal "don't write too many lines in a block" also applies. And some
namespace situations make that impossible, too...)
[mindlessly copied original post redacted]


Redaction connotes emmending, not snipping. Try "elided". ;-)


Thanks. Will do.
Best

Kai-Uwe Bux

Jun 4 '06 #8
Noah Roberts wrote:

Phlip wrote:
Can anyone think of an eviler style, seen in published code? ;-)


Yes.

http://code.axter.com/dynamic_2d_array.h

Google groups is likely to do wonders here...all of the following is on
4 concurrent lines:

dynamic_2d_arra y(size_t row, size_t col):m_row(row) ,m_col(col),
m_data((row!=0& &col!=0)?new T[row*col]:NULL){}

dynamic_2d_arra y(const
dynamic_2d_arra y&src):m_row(sr c.m_row),m_col( src.m_col),
m_data((src.m_r ow!=0&&src.m_co l!=0)?new T[src.m_row*src.m _col]:NULL){

for(size_t r=0;r<m_row;++r )for(size_t c=0;c<m_col;++c ) (*this)[r][c]
= src[r][c];

}

Guess he didn't want to waste any space or enter characters.


Reminds me of C64 basic code, where people used to write code in this style.
You could even leave out spaces between keywords and identifiers. The
common loop started like FORI=0TO10

Jun 4 '06 #9

Kai-Uwe Bux wrote:
Phlip wrote:
Kai-Uwe Bux wrote:
void Whatever() {
for (int i = 0; i < 100; i++) {
printf("whateve r\n");
}
}

Thats just dumb beyond dumb.

care to provide a reason ...


Because our last best hope for clarity among nested blocks is the ability
to see { in the same column as }.


I guess whether that poses a problem depends heavily on what you are used
to. I never found any difficulty with right-bracing in regard of clarity.
But then again, my blocks are not that deeply nested anyway.


I don't see it as a "problem" but braces on the next line are more
immediately readable to me.

Really, that is a small issue. The real issue is that whitespace
should at least be used somewhere and code should be written to be as
readable as possible without going really insain on the idea.

Jun 4 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.