Sunday, May 6, 2007

Partial classes and regions

Just read this blog post about using partial classes to separate the public interface and the private and protected members, which is a great idea.

This got me thinking of a problem I faced this week when working on using the MVP pattern for windows forms development.

One of the forms had two very distinct areas. The left side contained lists to lookup information and the right side displayed the details. This seemed to me like the perfect place to use two views. Now to implement two views in the same code-behind file you'd want some way to separate them. Regions goes some way to solving this, but it's hardly ideal. I'd much rather switch between partial classes in different files than between regions.

Now here's the issue... if you create another partial class to a windows form (in addition to the .Designer partial) the Visual Studio 2005 IDE automatically thinks it is another designer form. You would think they had thought of this scenario?

No comments: