473,402 Members | 2,055 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,402 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 1490
> 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.