Re: CSharp Coding Standards

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Mar 29, 5:44 am, aurat...@xxxxxxxxx wrote:

[snip]
Always have a default case in a switch statement that asserts:

int number = SomeMethod( );
switch(number)
{
case 1:
Trace.WriteLine("Case 1:");
break;
case 2:
Trace.WriteLine("Case 2:");
break;
default:
Debug.Assert(false);
break;

}

I like this pattern as well.

void Foo()
{
int number = SomeMethod();
switch (number)
{
case 1: /* blaa blaa */ return Something;
case 2: /* blaa blaa */ return SomethingElse;
}
return DefaultValue;
}


Do not use the this reference unless invoking another constructor from
within a constructor:


I care that much as long as the this keyword is used consistently or
not at all. Using it only half the time is pretty annoying.

Never call Thread.Join( ) without checking that you are not joining
your own thread:

That's too restriction. In fact, I can't think of situation where any
of my code could call Join on its own thread.


.



Relevant Pages

  • Re: Problem with linker
    ... but to have actually written a default constructor. ... such as overloading on int and pointer types. ... conversion of 0 to CString requires a user-defined conversion, ... acceleration operator *(distance d, time_squared t2); ...
    (microsoft.public.vc.mfc)
  • FAQ Suggestions
    ... It can only be applied to reference type variables converting to ... The .NET runtime can't guarantee that parameterless constructors will be ... performing by not having to call constructor code. ... number like casting an int to short) are always explicit. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Languages for embedded
    ... calling constructors of the structure's members. ... If I want to know whether xyz had a constructor, ... On the other hand, if I have a C struct xyz, and the API provides a ... If function ftakes an int by value, it can't modify any int value ...
    (comp.arch.embedded)
  • Re: How to escape the Ocamls superfluous parentheses and type declarations?
    ... > The constructor Mycons expects 2 argument, ... constructor applied to zero or more arguments. ... >> Because you haven't declared the union of char and int. ...
    (comp.lang.ml)
  • Re: Creating an object that is read from an input stream.
    ... > The Box class has a default constructor that leaves it's members undefined. ... the default constructor can put it into a valid state then. ... > int left, right, up, down; ... By 'invalid' do you mean uninitialized, or not initialized with the right values (if the default ...
    (comp.lang.cpp)