A quick look at how PostSharp compared to other implementations of AOP.
|
Static Weaving
PostSharp |
Transparent Proxy
Unity |
Dynamic Proxy
Spring.NET, Castle |
|
|---|---|---|---|
| Which elements of code can you enhance? | |||
| Methods implementing an interface | Yes | Yes | Yes |
| Virtual public methods | Yes | Only with MarshalByRefObject | Yes |
| Non-virtual public methods | Yes | Only with MarshalByRefObject | |
| Virtual protected methods | Yes | Yes | |
| Private, protected, static methods | Yes | ||
| External methods (defined in a different assembly) | Yes | ||
| Constructors | Yes | ||
| Fields | Yes | ||
| Properties | Yes | ||
| Events | Yes | ||
| Suitability for large projects | |||
| Compile-Time Validation | Yes | ||
| Robust Aspect Composition | Yes | ||
| Visual Studio Extension | Yes | ||
| Side effects | |||
| Ability to modify aspects after build | Yes | Yes | |
| No impact on build time | Yes | Yes | |
| No impact on architecture | Yes | ||
| Support for Silverlight & Windows Phone 7 | Yes | ||
Dependency Injection provides a level of de-coupling between objects and parameters, but requires extensive changes to your application architecture. Aspects can provide de-coupling without your application code even being aware of the associated behavior.
| Advantages | Disadvantages |
|---|---|
|
|
Leading products:
Spring.NET,
Castle.
See also:
LinFu,
fluentAOP.
Pure functional languages are compact and expressive, but can’t apply aspects across a system without extraneous boilerplate code. Composing aspects together in functional languages must be done manually; aspects can’t be composed automatically, as PostSharp does in .NET.
| Advantages | Disadvantages |
|---|---|
|
|
An orthogonal productivity technology, code generation can automatically create code from models and UI gestures, but cannot instrument existing source.
| Advantages | Disadvantages |
|---|---|
|
|
Leading products: T4, CodeSmith Generator.
While dynamic languages are powerful their power comes from their lack of restrictions. AOP couples the benefits of dynamic languages with a disciplined approach to software engineering.
| Advantages | Disadvantages |
|---|---|
|
|
While transformations eliminate one or two DLL dependencies, it takes a herculean effort to master. Plus, using MSIL requires abandoning the engineering discipline provided by .NET languages.
| Advantages | Disadvantages |
|---|---|
|
|
Leading products: Cecil, Microsoft CCI, PostSharp SDK
Aspect-oriented programming is a branch of discipline of software engineering that was specifically developed to address the issues of cross-cutting concerns. Static weaving uses low-level MSIL transformation internally, but does not expose the complexity of MSIL to developers.
| Advantages | Disadvantages |
|---|---|
|
|
Leading product: PostSharp
See also:
Afterthought,
AspectDNG,
Aspect.NET,
Compose*,
Gripper-LOOM.NET,
LinFu,
NSurgeon,
Phx.Morph/Wicca,
PostCrap
SheepAOP,
Snap