PostSharp

You may already know Aspect-oriented programming and how further decouple non business logic from the model. .Net has been using this paradigm across various frameworks like WCF by using attributes. Reflection has been for me the only reasonable way to exploit these attributes so far, which means the behavior is changed in runtime (which also added complexity). You also had to write down how this attributes are handled which didn’t help concentrating code.

PostSharp is a true AOP helper here, letting you completely describe the business and adorn the fields, methods and classes with .Net attributes. During a post-build step, the assembly is injected with some code based on those attributes. The aspects are encapsulated as attributes freeing the team from writing tons of repetitive lines. Decoupling aspects from the main logic also encourages code reutilization and increases maintainability by unifying scattered code in just one place. Although sometimes finding current crosscutting concerns in the code, or taking the effort to re-implement them as aspects can be overwhelming at first.

PostSharp 2.0 has gone even further allowing dependency solving which is something very promising (although its license may change).

Advertisements

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