Blog Stats
  • Posts - 24
  • Articles - 0
  • Comments - 61
  • Trackbacks - 92

 

Whidbey: Partial classes for Aspect-Oriented Programming?

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) { ... }
 }
}


Feedback

# re: Whidbey: Partial classes for Aspect-Oriented Programming?

Gravatar Iain, I have updated the post in light of your concern. Obviously other variations are possible. 10/19/2009 10:16 PM | tiffany key ring

Post a comment





 

 

 

Copyright © Eron Wright