Geeks With Blogs
Eron Wright - All Killer No Filler blog

I just realized that partial classes will encourage AOP.  A small example of this is with respect to import statements.  A class might have a dozen import statements.  Each import relates to specific functionality of the class.  If those functions are largely independent, you can now separate them into multiple partial classes, even within the same source file.  Consequently, the import statements are closely associated with the implementation.

For example, this code would appear within one file.  Obviously, only one class is being defined.

namespace Sample.Something
{
 using System.Web;
 using System.Web.Services;
 [WebService]
 public partial class FooService : System.Web.Services.WebService
 {
  [WebMethod] public Foo[] Search() { ... }  
 } 
}
namespace Sample.Something
{
 using System.Xml;
 using System.Xml.Serialization;
 public partial class FooService
 {
  internal void SerializeToXml(XmlWriter writer) { ... }
 }
}
namespace Sample.Something
{
 using System.IO;
 public partial class FooService
 {
  internal void WriteLog(Stream s) { ... }
 }
}

Posted on Monday, December 22, 2003 1:17 PM Technology | Back to top


Comments on this post: Whidbey: Partial classes for Aspect-Oriented Programming?

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Eron Wright | Powered by: GeeksWithBlogs.net