473,387 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A code formatter

Hi,

Does anyone know of a code converter that take code like this:

public Name
{
get
{
return name;
}
}

and turns it it to this:

public Name{
get{
return name;
}
}
Notice how the braces arent put onto another line. (Whats the point? To make
your work look bigger?)

If anyone know of something that could go through a file and alter the
layout, that would be a big help

Thanks All

Simon
Nov 16 '05 #1
11 1381
> Notice how the braces arent put onto another line. (Whats the point? To
make
your work look bigger?)


No, to make it less java-like...
Nov 16 '05 #2
B0nj <b123@nj> wrote:
Notice how the braces arent put onto another line. (Whats the point? To
make your work look bigger?)


No, to make it less java-like...


Um, most Java programmers use braces on separate lines in my
experience. Not all by a long shot, but most.

I have to wonder what purpose the OP feels that putting the closing
brace on a line on its own serves, if he's asking what the point of
putting the opening brace on a line on its own is.

To my mind, the point is to make it clearer where the block starts and
finishes.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
> I have to wonder what purpose the OP feels that putting the closing
brace on a line on its own serves, if he's asking what the point of
putting the opening brace on a line on its own is.


I prefer it that way. It looks a lot tidier in my view and with indenting
code blocks are very easily distinguished.
I don't really see the point of putting them there - It just takes up more
paper when you come to print the stuff out!

Of course its just my preference though

Simon
Nov 16 '05 #4
I have adopted the code block style myself which should not be
attributed to Java developers per se but rather to all developers having
learned to write clear and readable code from their C and C++
predecessors.

In any event, for those who prefer sloppy coding formats they should
know they will need to learn and use ctrl-[ brace matching more
frequently as they and others try to read and make sense of their code.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
I have to wonder what purpose the OP feels that putting the closing
brace on a line on its own serves, if he's asking what the point of
putting the opening brace on a line on its own is.
I prefer it that way. It looks a lot tidier in my view and with

indenting code blocks are very easily distinguished.
I don't really see the point of putting them there - It just takes up more paper when you come to print the stuff out!

Of course its just my preference though

Simon

Nov 16 '05 #5
Simon wrote:

Hi,

Does anyone know of a code converter that take code like this:

public Name
{
get
{
return name;
}
}

and turns it it to this:

public Name{
get{
return name;
}
}

Notice how the braces arent put onto another line. (Whats the point? To make
your work look bigger?)

If anyone know of something that could go through a file and alter the
layout, that would be a big help

Thanks All

Simon


If the MS Borg had done their formatter correctly (Format Selection: Ctrl+K,
Ctrl+F), they would have allowed customization of the reformatting
characteristics. It looks like they didn't (surprise!), too bad for us, we
must be assimilated.
Nov 16 '05 #6
I think DevStudio's regex-search&replace feature should be sufficient:
Search for ":b*\n:b*\{", replace with " {".
(Unforunately this won't recognize comments)

Niki

"Simon" <sh856531@microsofts_free_email_service.com> wrote in
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

Does anyone know of a code converter that take code like this:

public Name
{
get
{
return name;
}
}

and turns it it to this:

public Name{
get{
return name;
}
}
Notice how the braces arent put onto another line. (Whats the point? To make your work look bigger?)

If anyone know of something that could go through a file and alter the
layout, that would be a big help

Thanks All

Simon

Nov 16 '05 #7
which is bloody annoying since I seen lots of code samples originating from
them with aforementioned style. Resistance is futile :(

--
Br,
Mark Broadbent
mcdba , mcse+i
=============
"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com...
Simon wrote:

Hi,

Does anyone know of a code converter that take code like this:

public Name
{
get
{
return name;
}
}

and turns it it to this:

public Name{
get{
return name;
}
}

Notice how the braces arent put onto another line. (Whats the point? To make your work look bigger?)

If anyone know of something that could go through a file and alter the
layout, that would be a big help

Thanks All

Simon
If the MS Borg had done their formatter correctly (Format Selection:

Ctrl+K, Ctrl+F), they would have allowed customization of the reformatting
characteristics. It looks like they didn't (surprise!), too bad for us, we must be assimilated.

Nov 16 '05 #8
Select Tools, Options to get the Options dialog box. Then select the folder
Text Editor, C#, Formatting. In the Indentation section, make sure "Leave
open braces on same line as construct is checked". It is unchecked by
default.

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
"Mark Broadbent" <no************@no-spam-please.com> wrote in message
news:OO*************@tk2msftngp13.phx.gbl...
which is bloody annoying since I seen lots of code samples originating from them with aforementioned style. Resistance is futile :(

--
Br,
Mark Broadbent
mcdba , mcse+i
=============
"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com...
Simon wrote:

Hi,

Does anyone know of a code converter that take code like this:

public Name
{
get
{
return name;
}
}

and turns it it to this:

public Name{
get{
return name;
}
}

Notice how the braces arent put onto another line. (Whats the point?
To
make your work look bigger?)

If anyone know of something that could go through a file and alter the
layout, that would be a big help

Thanks All

Simon


If the MS Borg had done their formatter correctly (Format Selection:

Ctrl+K,
Ctrl+F), they would have allowed customization of the reformatting
characteristics. It looks like they didn't (surprise!), too bad for us,

we
must be assimilated.


Nov 16 '05 #9
Correction: that would be ctrl-] within the VS.NET IDE.
--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
URL http://www.metromilwaukee.com/clintongallagher/

"clintonG" wrote in message
news:u#**************@TK2MSFTNGP12.phx.gbl...
I have adopted the code block style myself which should not be
attributed to Java developers per se but rather to all developers having learned to write clear and readable code from their C and C++
predecessors.

In any event, for those who prefer sloppy coding formats they should
know they will need to learn and use ctrl-[ brace matching more
frequently as they and others try to read and make sense of their code.
--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
URL http://www.metromilwaukee.com/clintongallagher/

"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
I have to wonder what purpose the OP feels that putting the closing brace on a line on its own serves, if he's asking what the point of putting the opening brace on a line on its own is.
I prefer it that way. It looks a lot tidier in my view and with

indenting
code blocks are very easily distinguished.
I don't really see the point of putting them there - It just takes

up more
paper when you come to print the stuff out!

Of course its just my preference though

Simon


Nov 16 '05 #10
thx joe. guess it pays to look :)

--
Br,
Mark Broadbent
mcdba , mcse+i
=============
"Joe Mayo [C# MVP]" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:ux**************@TK2MSFTNGP12.phx.gbl...
Select Tools, Options to get the Options dialog box. Then select the folder Text Editor, C#, Formatting. In the Indentation section, make sure "Leave
open braces on same line as construct is checked". It is unchecked by
default.

Joe
--
Joe Mayo, Author/Instructor
Need C#/.NET training?
visit www.mayosoftware.com
"Mark Broadbent" <no************@no-spam-please.com> wrote in message
news:OO*************@tk2msftngp13.phx.gbl...
which is bloody annoying since I seen lots of code samples originating

from
them with aforementioned style. Resistance is futile :(

--
Br,
Mark Broadbent
mcdba , mcse+i
=============
"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com...
Simon wrote:
>
> Hi,
>
> Does anyone know of a code converter that take code like this:
>
> public Name
> {
> get
> {
> return name;
> }
> }
>
> and turns it it to this:
>
> public Name{
> get{
> return name;
> }
> }
>
> Notice how the braces arent put onto another line. (Whats the point? To
make
> your work look bigger?)
>
> If anyone know of something that could go through a file and alter the > layout, that would be a big help
>
> Thanks All
>
> Simon

If the MS Borg had done their formatter correctly (Format Selection:

Ctrl+K,
Ctrl+F), they would have allowed customization of the reformatting
characteristics. It looks like they didn't (surprise!), too bad for

us, we
must be assimilated.



Nov 16 '05 #11
"Simon" <sh856531@microsofts_free_email_service.com> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...

[opening brace on the same line as preceding code]
I prefer it that way. It looks a lot tidier in my view and with indenting
code blocks are very easily distinguished.
I don't really see the point of putting them there - It just takes up more
paper when you come to print the stuff out!


This is becoming a bit of a troll since code formatting preference is almost
a religion but nonetheless I feel my comments really matter so here goes.

Saving paper... It seems this is the one reason for not putting block
delimiters on the same vertical line. For clarity I see only drawbacks. When
was the last time you printed out a code file? This was done when
programmers only had line editors!

It is like one of those things that once had a pupose and just won't die
after the original reason for them vanished. Like underlining text to
emphasise, which was once the only way for type writers to emphasise
anything.

Be it "begin" and "end" or "{" and "}", compound statement delimiters should
be either on separate lines starting in the same column or optionally both
on the same line if the statement enclosed is more trivial than the compound
construct itself.

I feel it is a good thing that Microoft or any other tool vendor sets
standards for things like formatting and naming conventions, ideally they
should be part of the language. We will probably continue to see people use
bMyBooleanVariable and strMyStringVariable for quite a while, which was once
the only way to make the lack of type safety a bit less dangerous. I catch
myself still using prefixes for GUI controls as in tbxAmount where it should
be amountTextBox. Old habits die hard...

Martin.
Nov 16 '05 #12

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

Similar topics

1
by: farseer | last post by:
Hi, does anyone out there use Eclipse 3.0.1 as their Java Editor? >From menu "Window->Preferences->Java->Code Style->Code Formatter", i created a new Code Formatter profile and set it up how i...
0
by: Christopher Pragash | last post by:
Hello All, Recently I had posted a message to forum requesting assistance to resolve a security issueI was facing in .NET Framework 1.1, the error being "Because of Security Restrictions, the...
1
by: CLEAR-RCIC | last post by:
I have a piece of code that works in C# but when I convert it to VB.Net I get the following error: "Cannot deserialize the message passed as an argument. Cannot recognize the serialization format."...
4
by: Patrick De Ridder | last post by:
Which library should I include for the formatter in formatter.Serialize(output, record); Many thanks. -- Patrick De Ridder ngmail@freeler.nl
4
by: Andreas Huber | last post by:
Hello there I need to serialize/deserialize some pretty simple data structures (no inheritance, few has relationships, ~20 classes) in three formats. One is XML (structure is not important as...
1
by: andrew | last post by:
I was earlier trying to persist a windows forms control to disk using the binary formatter class. I have devised a workaround, however I have Classes added in as references to my project which...
2
by: alexandre martins | last post by:
Every time i try to make Deserialize the computer gives me the folowing error: "End of Stream encountered before parsing was complete" the code that i'm running is simple and is based on an...
8
by: Surendra Singhi | last post by:
Hello, Are there any good open source C/C++ source code formatter? Thanks for your help. -- Surendra Singhi http://www.public.asu.edu/~sksinghi/index.html ,---- | "O thou my friend! The...
0
by: apexi.200sx | last post by:
Just wondering if anyone could give me advice on handling potential error conditions in python, it seems that exceptions are used alot more for this stuff than in other languages. I have...
1
by: dileepd | last post by:
Hi Every one, Could you please let me know if you have any clue about following things. 1. Whether type bool acts like a kind of signed int type in g++ on solaris 9(a/c to my invetsigation it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.