My 1st .NET / C# impressions

[quote]Nothing that much wrong if the if statement is just one line. What is REALY bad is

if (a > i)
somethingugly()

of course it might be used with for as well.
[/quote]
I should probably not let you read my code then… :wink:

[quote] would have to say that the near-perfection of Eclipse’s code formatter should relegate these religious whitespace arguments to a thing of the past.
After ctrl-s, my most-used shortcut is esc,ctrl-f.
[/quote]
Amen to that. Although it does mess with some stuff… Why can’t it let local variables be formatted nicely as class fields? And it messed with nice things like

if (abc) do.the.thing();
else if (bcd) do.the.other.thing();
else if (cde) do.something.else(),

I like nice lineups!

That is the WORST! What you have below is better. Why? because the body of the IF should always be placed in the same spot to improve readability. The only time I would do something like above is if I had several trivial (very short) conditions in a row so the pattern of the body being on the same line as the condition was obvious and the block of IFs could be easily seen as a unit. In that case I might also align the body code to start at the same column.

This is an improvement becase the body is indented below the IF which is the same case as a multi-line body. So you don’t have to mentally parse two different formats. I only omit braces when the if condition and the body, as well as any else/elseif and associated body are all one liners. So if the if body is one line, but the else body is two lines, then both bodies get braces. Or if I have a complex condition that spans more than one line I use braces, e.g.:


if( conditionA
  & conditionB
  & conditionC )
{
    doStuff();
}

I know it’s all a matter of opinion, but at least I have logical reasons to back my opinion up :stuck_out_tongue:

And what if you’d have

if (something)
somethingUgly();
somethingUgly2();

Is it just a typo, or bad tabs?

You know, one of the things I liked the most about a language called GFA Basic that I used to use, was that you didn’t have any choice whatsoever, it laid it out for you as you typed. Genius.

Cas :slight_smile:

Yeah, GFA basic had a great editor for its time. It could even collapse methods, something which has just recently been added to Eclipse.

Recently? This was pretty common in assembly IDEs.

The first time I used Python is felt strangely odd for formatting to actually matter to the compiler/interpreter (as instead of {} you use indent levels). However after a while it becomes natural and it means that code is always consistantly formatted (assuming it runs, that is).

Compared to when GFA was used, it was added to Eclipse like yesterday :slight_smile:

[quote]You know, one of the things I liked the most about a language called GFA Basic that I used to use, was that you didn’t have any choice whatsoever, it laid it out for you as you typed. Genius.
[/quote]
heh… that’s the thing I hate about visual basic… it messes with my formatting!

I say: “Leave my code alone unless I tell you to!”…

of course you can turn it of in vb but then the editor behaves strangely, and all wizard code is all messy and has to be straighten out…

The thing with vb is also that no matter how you format it, it will look ugly (even in vb.net with its weird naming conventions).
But yes, if your attempts at making it look better using formatting are being punished by strangely behaving editors and wizard code, well, that just sucks.

I started programmed my first game in GFA Basic back in the late 80’s. Before I finished it I learned C and switched to MegaMax C on the Atari ST. The event loop was effortless.