The type ” is made of several partial classes in the same file

Practical Software Masochism™ has hit a new bottom:

http://msdn.microsoft.com/en-us/library/bb129230.aspx

Some errors are not likely to happen. I mean, why on earth would someone try to create multiple partial class declarations in the same file?

http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sourceanalysis

SA1201: ElementsMustAppearInTheCorrectOrder

When implementing an interface, it is sometimes desirable to group all members of the interface next to one another. This will sometimes require violating this rule, if the interface contains elements of different types. This problem can be solved through the use of partial classes.

1. Add the partial attribute to the class, if the class is not already partial.

2. Add a second partial class with the same name. It is possible to place this in the same file, just below the original class, or within a second file.

3. Move the interface inheritance and all members of the interface implementation to the second part of the class.

Well, I guess I have to use multiple files then. But I’m not sure how that could possibly

“increase the readability and maintainability of the file and encourage code reuse.”

Advertisements
This entry was posted in Coding Horror. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s