Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 2nd, 2006, 6:05 PM   #1
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
C# Coding Standard

I wanted to know if anyone knows the C# Coding Standard from idesign and what one thinks of them.

I think they are kind of pushy on some things.
I also don't agree with their member variables having a name that starts with m_ . Underscores are not for OOP, this of course is my personal opinion, but I don't see any underscores in the API either.
I also don't agree that many assertions should be made, like it says:
using System.Diagnostics;

object GetObject()
{...}

object someObject = GetObject();
Debug.Assert(someObject != null);
This strikes me as odd, because I'd _always_ check for null, so I'd use:
if(someObject != null); instead of Debug.Assert().

I come from a C/C++, Java background so C# is easy, but can someone tell me if I should use the internal keyword and when I should use it instead of private or protected?

One last English question: Under "Naming Conventions and Style", #24 it says:
Quote:
Originally Posted by C# Coding Standard
Always place an open curly brace ({) in a new line.
Shouldn't that be on instead of in?
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Mar 3rd, 2006, 12:59 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
OK, let's see... my advice: take what ya like, and disregard or make up new rules when you don't like something. The best coding standards are ones you write yourself.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Mar 3rd, 2006, 1:20 PM   #3
MBirchmeier
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 211
Rep Power: 4 MBirchmeier is on a distinguished road
Quote:
Originally Posted by nnxion
I wanted to know if anyone knows the C# Coding Standard from idesign and what one thinks of them.

I think they are kind of pushy on some things.
I also don't agree with their member variables having a name that starts with m_ . Underscores are not for OOP, this of course is my personal opinion, but I don't see any underscores in the API either.
I appreciate this convention, and here's my reason why:

If private/protected variables are all given an m_ followed by a descriptive name you can use names for function arguments freely without having to worry that one might already be in use. It also prevents accidental masking of what should be standard names. This is the only place I use the '_' and IMO helps re-enforce OOP principles.

Quote:
I also don't agree that many assertions should be made, like it says:
using System.Diagnostics;

object GetObject()
{...}

object someObject = GetObject();
Debug.Assert(someObject != null);
This strikes me as odd, because I'd _always_ check for null, so I'd use:
if(someObject != null); instead of Debug.Assert().
The debug.assert is used mainly for development time and not runtime. 'Release' builds generally ignore Debug class statements (more information here

Quote:
I come from a C/C++, Java background so C# is easy, but can someone tell me if I should use the internal keyword and when I should use it instead of private or protected?
I got the impression the internal keyword opened a function up to anything declared within the namespace, and nothing further I personally don't like to rely on this because frankly I don't like the idea. I either prefer to add it to an interface for use, or restrict it, just saying well i'm making this code so i'll make sure I don't fudge things up isn't a habit I want to get into.

Quote:
One last English question: Under "Naming Conventions and Style", #24 it says:

Shouldn't that be on instead of in?
It depends on if you see a line as a container for code, or a surface on which code resides ... it's all the same though.

-MBirchmeier
MBirchmeier is offline   Reply With Quote
Old May 9th, 2006, 10:52 PM   #4
Kaja Fumei
Hobbyist Programmer
 
Join Date: Oct 2005
Posts: 134
Rep Power: 4 Kaja Fumei is on a distinguished road
Quote:
Originally Posted by MBirchmeier
I got the impression the internal keyword opened a function up to anything declared within the namespace, and nothing further I personally don't like to rely on this because frankly I don't like the idea. I either prefer to add it to an interface for use, or restrict it, just saying well i'm making this code so i'll make sure I don't fudge things up isn't a habit I want to get into.
To quote MSDN:
Quote:
Originally Posted by MSDN
Internal types or members are accessible only within files in the same assembly
The main purpose of internal is if you are building a library, internal means only classes inside the library can access the method, field, class or whatever is delcared "internal". Therefore, classes in other "assemblies" (other libraries or programs) that use the library will not have access to anything in the library that is declared internal.

You can also use "protected internal" which is like internal but also allows access in any classes derived from the classes containing the internal data or methods.
Kaja Fumei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:08 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC