Whidbey: Hopefully to implement alternativ code layouts in C#

  • Thread starter Thread starter Axel Dahmen
  • Start date Start date
A

Axel Dahmen

I've just read about the new Whidbey, which I think gives great features to
the programmer.

The HTML editor comes with a bunch of great formatting options. It'd be
great if C# would get some of these options, too. I, for example, prefer to
write code using indented braces, like:

byte x()
{byte i=1;

if (y(i))
{i+=1;
z(i);}

return i<<1;}

and would quite appreciate if C# supported this kind of formatting when
automatically reformatting my code.
 
Axel Dahmen said:
I've just read about the new Whidbey, which I think gives great features to
the programmer.

The HTML editor comes with a bunch of great formatting options. It'd be
great if C# would get some of these options, too. I, for example, prefer to
write code using indented braces, like:

byte x()
{byte i=1;

if (y(i))
{i+=1;
z(i);}

return i<<1;}

and would quite appreciate if C# supported this kind of formatting when
automatically reformatting my code.

I very much doubt that that'll be an option, simply because it's not a
commonly used formatting style - I don't recall ever seeing anyone use
it for any of Java, C, C++ or C#. I'm sure there are other programmers
out there who use it, but probably not enough to make it worth MS
spending the time implementing a formatting style for their/your
benefit.
 
Axel Dahmen said:
I've just read about the new Whidbey, which I think gives great features to
the programmer.

The HTML editor comes with a bunch of great formatting options. It'd be
great if C# would get some of these options, too. I, for example, prefer to
write code using indented braces, like:

byte x()
{byte i=1;

if (y(i))
{i+=1;
z(i);}

return i<<1;}

and would quite appreciate if C# supported this kind of formatting when
automatically reformatting my code.

That has got to be the worst coding style I have ever seen. Let's be
frank... if you were to present this as your sample code at a job interview
with me, I would immediately show you the quickest way to the back door...

byte x()
{
byte i = 0;

if (y(i))
{
i += 1;
z(i);
}

return i << 1;
}

That is the correct style, and promotes the concept of easy identifiable
code blocks by aligning the opening and closing braces... though I would
grudgingly accept the following (with a signed letter of intent to change to
the above format for continued gainful employment):

byte x() {
byte i = 0;

if (y(i)) {
i += 1;
z(i);
}

return i << 1;
}

Why people insist on saving one line of code in favor of far more difficult
code readability and maintenance? I have no idea.
 
Why people insist on saving one line of code in favor of far more difficult
code readability and maintenance? I have no idea.

Because they think this format makes the code MORE readable rather
than less, perchance? Saving "one line of code" per construct shows a
lot more code when you have ten constructs on a page, and the editor
only shows 25 lines or so at once. Less vertical whitespace also
means fewer visual disruptions, especially when the leading and
following statements are closely related (as they often are).

Of course this format is harder to read in the way YOU wrote it,
because you used too little indendation -- the standard is four
spaces, not two. Note that monitors are wider than they're high...
 
FYI:

This is a new feature, which microsoft plans to ship with
Whidbey.
You can have your own defined formatting style on your C#
code.
So it would be possible for Axel to format the code in his
own (ugly) way.

Sunil TG
 
Sunil TG said:
This is a new feature, which microsoft plans to ship with
Whidbey.
You can have your own defined formatting style on your C#
code.
So it would be possible for Axel to format the code in his
own (ugly) way.

While I'm sure you can define your own formatting style to *some*
extent, I doubt that you'll have free reign to do *everything*. For
instance, Jalopy allows various different styles of Java formatting,
but I don't think it would provide a way of formatting to Alex's style
(without changing the code, anyway).
 
I perfectly agree with you, Christoph.

Got no more points to add here. Well, except for one sidekick regarding the
other style: I think it's mainly used by examples and therefore by beginners
until they evolve the other style for the reasons mentioned by you. Got the
same discussion running back at my job.

---------
 
I think that's rather short sided. The logic of the code is what dictates
it's value more than anything else. Let's say that Windows was written with
that formatting, there'd be a bunch of talented programmers unemployed if
you were Bill Gates and the OS would work exactly the same.

I think you're are being a little unnecessarily hard on the guy because if
he wants to format it a certain way so be it. There's no coding format
rules that I have come across although there are guidelines. And provided
he comments his code (something wayyyy to few programmers do) adequately, it
Will be readable.
 
The Posting One said:
Why people insist on saving one line of code in favor of far more difficult
code readability and maintenance? I have no idea.

Because my programming career started with learning from the first edition
of K&R C, which was the bible at the time. Been doing it that way ever
since (1985).

-- Alan
 
The HTML editor comes with a bunch of great formatting options. It'd be
great if C# would get some of these options, too. I, for example, prefer to
write code using indented braces, like:

You must be the only person that thinks the HTML editor provides "great
formatting options." :) VS.Net is quite possibly the only program I've ever
seen that will take perfectly correct and valid HTML and convert it into a
complete mess of random line breaks in addition to spewing out a mish-mash
of upper- and lower-case attributes that don't conform to any accepted
standards.

If the way it handles HTML is anything to go by, I'd appreciate VS.Net
keeping its grubby little paws off my C# code. I like my code to compile
thank you very much.

Colin
 
You are damn right. It's really difficult to live with the HTML editor's
interpretation of a "well shaped document". :)

Meanwhile I have evolved some tricks to keep it from ruining my html: To
copy the control IDs into the code-behind, I 1) save the HTML source, 2)
switch to Design View, 3) press [F7] to have VS.NET copy the control IDs
into the code-behind, 4) go back to the HTML window, and 5) close that
window without saving. Cumbersome, but it's a fair workaround so far...

But Microsoft promises to get straight in
http://msdn.microsoft.com/asp.net/whidbey/default.aspx?pull=/library/en-us/d
naspp/html/webdevinwhidbey.asp
and I'm really looking forward to see this work.


------------------------
 
Back
Top