CSharpFeeds - All your C# feeds in one place.

Sponsors

Wednesday, May 23, 2007

My C# Naming Conventions For Partial Class Files

by Paulo Morgado via Paulo Morgado : C# on 5/23/2007 11:29:32 PM

Following up on a previous post, this time I'll give you my naming conventions for partial class files.

There are two main reasons for me to break a class definition into more than one file. The main one is when I have inner classes and the other is when the file is getting too big.

How should I name the files? The usual tendency is to use a “.” as separator. This looks nice until you came across something like this:

public class MyComponent

{

    private class Activation

    {

        // Class implementation.

    }

 

    private class Deployment

    {

        // Class implementation.

    }

 

    #region Event Handling

 

    // Event handling code.

 

    #endregion

}

If I would extract the inner classes and use the “.” as separator, I would end up with the following list of files:

  • MyComponent.Activation.cs
  • MyComponent.cs
  • MyComponent.Deployment.cs

And, what about the long event handling code? Should I do the same? If so, I will end up with the following list of files:

  • MyComponent.Activation.cs
  • MyComponent.cs
  • MyComponent.Deployment.cs
  • MyComponent.EventHandling.cs

This doesn’t look very nice, does it?

So, here is my proposal:

  • “-“ separator for code from the top class
  • “+” separator for inner classes

This way, I end up with the following list of files:

  • MyComponent.cs
  • MyComponent-EventHandling.cs
  • MyComponent+Activation.cs
  • MyComponent+Deployment.cs

And this looks a lot nicer.

email it!bookmark it!digg it!

Original Post: My C# Naming Conventions For Partial Class Files

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us