473,233 Members | 3,513 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,233 software developers and data experts.

Coding Conventions?

I realize that you people have not seen much of me other than some framework
responses I have posted.

I am primarily a VB guy (yes, you can laugh) But I have lurked here for
several years, picking up little crumbs of C# wisdom.

Perhaps it's just my style, but what's this annoying behavior of the IDE and
how do I stop it:

C# seems to want me to write all my code like this:

public class Foo
{
public void DoThis()
{
// code here
}
}

What I REALLY want is to write my code like this:

public class Foo {
public void DoThis() {
//code here
}
}

Things like loops, IF and CASE blocks get really irritating when they use
the lengthy expanded format that the IDE seems to enforce, and I really want
the code window to behave like how I think. Is there some option or
template that I have to modify?

Also, while I'm at it, how do you all prefer to write? Expanded curly
braces? Brace on the sig line? whole programs in one big long line of
text? I guess here, I am just asking how the rest of you prefer to write
code.
--
Peace & happy computing,

Mike Labosh, MCSD MCT
"Escriba coda ergo sum." -- vbSensei
Jan 22 '06 #1
4 1484
> Things like loops, IF and CASE blocks get really irritating when they use

Whoops, that's my VB drain bramage showing its head. I mean SWITCH blocks.

--
Peace & happy computing,

Mike Labosh, MCSD MCT
"Escriba coda ergo sum." -- vbSensei
Jan 22 '06 #2
Mike,

Go to "Tools | Options". On the dialog that pops up, go to "Text Editor
| C# | Formatting"

Under there, past "General", there is "Indentation", "New Lines",
"Spacing" and "Wrapping".

That should allow you to set everything that you want. For your
specific braces issue, you want "New Lines" and then you want to UNCHECK the
following:

Place open brace on new line for types
Place open brace on new line for methods
Place open brace on new line for anonymous methods
Place open brace on new line for control blocks

As for my style, I prefer to code like this:

public
class
MyClass
{
public
MyClass
(
)
{
}
}

But that's just me.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike Labosh" <mlabosh_at_hotmail.com> wrote in message
news:u7*************@tk2msftngp13.phx.gbl...
I realize that you people have not seen much of me other than some
framework
responses I have posted.

I am primarily a VB guy (yes, you can laugh) But I have lurked here for
several years, picking up little crumbs of C# wisdom.

Perhaps it's just my style, but what's this annoying behavior of the IDE
and
how do I stop it:

C# seems to want me to write all my code like this:

public class Foo
{
public void DoThis()
{
// code here
}
}

What I REALLY want is to write my code like this:

public class Foo {
public void DoThis() {
//code here
}
}

Things like loops, IF and CASE blocks get really irritating when they use
the lengthy expanded format that the IDE seems to enforce, and I really
want
the code window to behave like how I think. Is there some option or
template that I have to modify?

Also, while I'm at it, how do you all prefer to write? Expanded curly
braces? Brace on the sig line? whole programs in one big long line of
text? I guess here, I am just asking how the rest of you prefer to write
code.
--
Peace & happy computing,

Mike Labosh, MCSD MCT
"Escriba coda ergo sum." -- vbSensei

Jan 22 '06 #3
> Also, while I'm at it, how do you all prefer to write? Expanded curly
braces? Brace on the sig line? whole programs in one big long line of
text? I guess here, I am just asking how the rest of you prefer to write
code.


For what its worth, I do prefer the default formatting. Braces on seperate
lines, class and method definitions on one line(with the exception of the
where operator or inheritets\implements lists of more than about 3 items,)
and statements taking one line each. I was quite pleased when I launced
VS.NET the first time and found the C# conventions to be almost exactly to
my liking.
Jan 22 '06 #4
Consistency is more important that the style you actually use, especially if
you code as part of a team. You want all code to look like it could have
been written by anyone within the team, and that any team member making
changes doesn't have to "think" about formatting style, since after a few
months of applying a consistent coding style it becomes second nature. If
you're a one-person developer you don't have these issues obviously, but
consistency is still important.

At my previous job I did not put opening curly braces on a line by
themselves - UNLESS they were for a class declaration or the opening body of
a function (classic C K&R style). My opinion back then was that if K&R
invented the language, so am I to argue about their formatting style?

But C# is not truly C, so I take some liberties with it. Really short
methods you might find writing on a line by themselves, like C++ inline
methods. For example, in C#:

public abstract string MyProperty( ) { get; }

Padding this out to multiple lines serves no useful purpose and in my
opinion actually reduces the clarity of the code, since there is no
implementation anyway.

At my new job braces go on a line by themselves, but we still have enough
flexibility to allow for the above convention where the construct is short
enough to warrant it (we effectively apply our C++ coding conventions -
where they make sense - to C#).
"Mike Labosh" <mlabosh_at_hotmail.com> wrote in message
news:u7*************@tk2msftngp13.phx.gbl...
I realize that you people have not seen much of me other than some
framework
responses I have posted.

I am primarily a VB guy (yes, you can laugh) But I have lurked here for
several years, picking up little crumbs of C# wisdom.

Perhaps it's just my style, but what's this annoying behavior of the IDE
and
how do I stop it:

C# seems to want me to write all my code like this:

public class Foo
{
public void DoThis()
{
// code here
}
}

What I REALLY want is to write my code like this:

public class Foo {
public void DoThis() {
//code here
}
}

Things like loops, IF and CASE blocks get really irritating when they use
the lengthy expanded format that the IDE seems to enforce, and I really
want
the code window to behave like how I think. Is there some option or
template that I have to modify?

Also, while I'm at it, how do you all prefer to write? Expanded curly
braces? Brace on the sig line? whole programs in one big long line of
text? I guess here, I am just asking how the rest of you prefer to write
code.
--
Peace & happy computing,

Mike Labosh, MCSD MCT
"Escriba coda ergo sum." -- vbSensei

Jan 23 '06 #5

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

Similar topics

3
by: Roman Roelofsen | last post by:
Dear python-list, while looking for some coding conventions for python programs, i found the PEP8 at http://www.python.org/peps/pep-0008.html. It defines the rules very well and leaves no space...
3
by: David Inada | last post by:
w3c talks about scripting and gives examples. But I could not find a coding standard for ASP/VBScript. I am trying to find any standards and tools to apply those standards to my companies...
1
by: jarit | last post by:
Hi, Found these coding guidelines for C#, HTML, Javascript, Java, HTML, PL/SQL, T-SQL, VB and VBScript. Well written and free to download. www.demachina.com/products/swat Jeroen
9
by: Neil Zanella | last post by:
Hello, Some programmers like to use a coding convention where all names of variables that are pointers start with the letter p (and sometimes even use similar conventions for strings and other...
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
7
by: Ralph Lund | last post by:
Hi. I am starting a new project with C#. I am searching for "good" coding conventions. I know that there are some coding conventions from microsoft, (but they are very extensive and not clear)....
6
by: Andrea Williams | last post by:
Responding to this link in an old thread: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht ml/cpconnetframeworkdesignguidelines.asp According to that naming...
4
by: Dotnetjunky | last post by:
Hi, So far, I've found tons of documents describing recommended coding standards for C#, but not a single piece on VB.NET yet. Anybody here knows such a coding standards guideline on VB.NET...
4
by: Josh Golden | last post by:
i lead a small development team (based on some of my posts that might cause some people to choke themselves, but have no fear, i am NOT the lead developer, the people on my team are great - i'm...
19
by: auratius | last post by:
http://www.auratius.co.za/CSharpCodingStandards.html Complete CSharp Coding Standards 1. Naming Conventions and Styles 2. Coding Practices 3. Project Settings and Project Structure 4....
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.