|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
Introduction In the days where business agility is becoming the
definite need of any business / IT infrastructure, quite frequently we are
ending up with facing the scenarios, where we need to develop applications that
are flexible and easily manageable.
The flexibility in an application’s architecture is
demanded by the emerging business competitions, pressure to sustain the challenges created
by the innovative business models, need to sustain the growing customer’s base
of an established business etc. Say for example you are building an e-commerce
system with an innovative business model, targeting a niche market. Soon, it is
becoming hot in the market and your system is witnessing a rapidly growing user
base, in a short span of time. The system starts crawling, failing to sustain
the increased user load there by creating significant loss to your business and
to the good will you have created with your hard work and innovation.
Situations that may pull your business down may be
like:
- Changes
in the regulations / policies of the government because of which you may need
to incorporate some more rules in to your system, while keeping it running
- Need
to switch from your payment gateway to an other one who is offering services at
a discounted price , to increase the revenue
- Need
to shift from one packaging company to other (like say from FedEx to UPS) as
there is a need to increase of the speed of the delivery
- Demand
to shift from a particular financial outsourcing services provider to another
- Etc...
The architecture that could excel in such an agile
environment can be called “Pluggable Architecture”. There are proven
methodologies (Patterns) that can constitute the design to realize such
architectures. AOP is one of such available patterns / methodologies widely
adopted in the market.
Background
AOP – Aspect Oriented Programming is a methodology
that helps in keeping the “cross-cutting concerns” separate from the code
blocks that encapsulate business logic. “cross-cutting” here refers to the code
blocks that are non-business specific and that are repeated across different
classes spread across different layers. Examples of cross cutting concerns are:
Logging, Exception Handling code blocks specific to instrumentation of the code
etc. There may be many numbers of such concerns which need to be abstracted
from the business logic specific code. The basic thumb rule to identify a
cross-cutting concern is: If a concern is repeated across classes spread over
layers / tiers, then it is a cross-cutting concern.
AOP Benefits
The facility to separate the cross-cutting concerns
helps in:
- Selectively
applying the cross cutting concerns, as required. Say some logic related
to profiling the code for performance monitoring would required only at
the time of testing but not in the production environment so they can be
enabled/disabled based on the environment as required
- Applying any changes / fixing bugs in the
cross-cutting code logic, without affecting the business logic code in the
production environment.
- Evolution
of the different parts of the system in different paces.
- Arriving
at a final solution where the code is easy to understand and maintain
Need for a Rating Methodology
Having realizing the benefits of AOP, the next step
is to look for ways to implement it in our application development. In this case,
instead of starting from scratch, the best way is to leverage the research and
effort put by many of hardworking tech savvies around the world through the
availability of open source frameworks / utilities.
When we are in the stage of looking for adopting an
open source AOP framework, lots of open source AOP frameworks are available in
the market and hence, we need to choose the best possible one for our
development. Choosing the best possible one could be a difficult task as always
there will be conflicts of thoughts and difference of opinions, especially when
we are in a team. Especially when we are in a position to convince our
customers for the adoption of a particular framework, we cannot choose a
particular AOP framework, unless and otherwise we have some good
justifications.
Will it not be good, if we have rating methodology
where we can analyze and evaluate the available AOP frameworks qualitatively
and quantitatively enabling us to rate the AOP frameworks in the market so that
we can make an informed decision in a short span of time. Result of such a
thought process is the following “Frameworks Rating Methodology”.
Open Source AOP Frameworks Rating Methodology As a part of this effort, I had identified some of
the attributes (which can be expanded / refined) and assigned points for each
of the AOP framework (which is subjective – It is based on my research and
information available to me. You can change it as per your observation and conviction)
The list of the open source AOP frameworks that
are considered for this rating process are:
·
Aspect#
·
AspectDng
·
NAspect
·
PostSharp
·
Policy Injection
Application Block
·
Sesar
·
Spring.Net
[Spring.AOP]
The Rating attributes identified and used for this
rating process are:
|
Quality of the Methodology adopted
|
There
are different approaches available to achieve AOP in .Net. Each of the
available open source AOP frameworks adopted different approaches. Basically
AOP can be achieved either at compile time or at runtime. According to me ,
runtime will be always a overhead when compared to compile time, as it is a
one time process.
Details
on the available approaches available at :
http://www.ayende.com/Blog/archive/2007/07/02/7-Approaches-for-AOP-in-.Net.aspx
When
I was investigating on the details of approach adopted by these open source
frameworks, information clarity is available only for some of the frameworks.
I had assigned points based on my thought process and perception. It may
differ from person to person based on the availability of the information and
depth of the research.
|
|
Community support
|
When
we choose a particular open source framework for our development projects,
unless and otherwise there is a wider community support, we cannot go with it,
as it may be a high risk during the course of deployment or in the later stage
of production support.
|
|
Visibility of any Implementations / Industry-wide adoption
|
Again,
as a part of finalizing architecture for a solution, our clients may be
looking for proven case studies / industry wide adoptions of the products
that we choose. Same thing is applicable here as well. Availability of proven
case studies will provide us some confidence on that framework especially
when we go for large scale, enterprise level solution development. In this
investigation process, I could rarely see any proven case studies for any of
these listed frameworks.
|
|
Ease of adoption by developers
|
This
is again subjective and can vary from person to person.
|
|
Learning curve required
|
This
is again subjective and can vary from person to person.
|
|
Memory Footprint / overhead
|
This
could be a key attribute on rating a particular framework. Only some of the
framework’s groups are explicit on memory foot print of their products. As
this could be a significant factor affecting the performance and resource
consumption especially on large scale deployments, I would suggest the
respective framework providers to publish benchmark case studies / lab
results, which would provide us good confidence on the framework.
|
|
Available version in the
market (Is it a RC or still in alpha
stage)/ Documentation
|
Some
of the frameworks on its early stages development. Periodical releases of the
subsequent versions of the frameworks are the indications of the aggressive
development and enthusiasm of the community behind those frameworks. Also,
availability of the documentation (API, Conceptual, and Architecture) is a
definite need for any framework to understand them clearly.
|
I have assigned very low points if the information
is not clear or if it is not available or if it is vague.
|
Guidance
for Rating Attributes
|
- 0 – bad , Not
known, Not clear, sufficient information not available
|
- 1 – To be
improved , some info is available
|
- 2 – Good ,
sufficient info is available
|
- 3 – Very Good ,
no major overhead, no major memory footprint, Excellent info is
available
|
Here is the resulting rating
matrix:
|
Preliminary Rating
Matrix
|
|
Available
Open Source .Net AOP Frameworks / Utilities
|
|
|
NAspect – Puzzle.Net
|
Aspect#
|
Policy Injection Application Block
|
PostSharp
|
Seasar
|
AspectDng
|
Spring.Net
|
|
|
|
|
|
|
|
|
|
|
Quality of the Methodology adopted
|
2
|
2
|
2
|
3
|
2
|
2
|
2
|
|
Community support
|
2
|
2
|
3
|
3
|
1
|
1
|
3
|
|
Visibility of any Implementations / Industry-wide adoption
|
1
|
0
|
2
|
2
|
0
|
0
|
1
|
|
Ease of adoption by developers
|
2
|
1
|
2
|
3
|
2
|
1
|
2
|
|
Learning curve required
|
1
|
1
|
2
|
3
|
1
|
1
|
2
|
|
Memory Footprint / overhead
|
1
|
0
|
1
|
3
|
0
|
0
|
1
|
|
Available version in the
market (Is it a RC or still in alpha
stage)/ Documentation
|
2
|
2
|
3
|
3
|
2
|
1
|
3
|
|
|
|
|
|
|
|
|
|
|
Total
|
11
|
8
|
15
|
20
|
8
|
6
|
14
|
Conclusion
Whenever we go for implementing a particular
methodology or concept like AOP, we will always leverage the existing open
source frameworks. Since there is a no. of open source frameworks available in
the market, it will be always good to have some concrete justifications as a
base for selecting a particular framework for adoption.
Adopting a rating
process some thing like explained in this article will ensure that the
frameworks are subjected to both qualitative & quantitative evaluation
process, resulting in a meaningful decision. From the matrix, the frameworks that emerged in the
‘top 3 ‘list of are:
·
PostSharp
·
Policy Injection
Application Block
·
Spring.Net
[Spring.AOP]
| You must Sign In to use this message board. |
|
| | Msgs 1 to 9 of 9 (Total in Forum: 9) (Refresh) | FirstPrevNext |
|
 |
|
|
Some very interesting info in your article, but you missed out DynamicProxy from the Castle project[^] which project is currently using. Personally, I'd find it really interesting to know the runtime performance overhead of each solution.
Overall though, a very interesting article and a good attempt at rounding up what's out there. Well done!
Cheers, John
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, why havn't you tested LOOM.NET[^]? They have two aspect weavers for .NET, a dynamic weaver called Rapier-Loom.NET and a static aspect weaver called Gripper.Loom.NET.
Best regards,
Wolfgang.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
I've personally evaluated most of these trying to find a good tool. This chart doesn't really show how much better PostSharp is to it's competitors; and frankly I'm surprised the Spring.NET even broke double digits - that's the most bloated, cumbersome, beast I've ever seen.
PostSharp really deserves a 200 on this scale because you will find that is 10 times better than anything else out there - trust someone else who had to go out and find a good AOP tool!
In fact if Microsoft was smart they contact Gael, and make him an offer and incorporate his framework into the next version of .NET - that's how awesome it is.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
On "memory footprint/overhead", how can a tool which adds some MSIL to existing dlls consume any overhead memory ? Thus, how can you put 0 on this tool ?
Weaving MSIL to a dll can't had any overhead, as there is no dependency on the framework during runtime. This should be on the contrary the ONLY tool to deserve a 3.
This sort of result could let me think you have not tested those tools. Do you have an explanation for this I might not see ?
Regards
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
I might have missed something, but which of the frameworks are you refering to? I've only really looked at PIAB and PostSharp, and even though the latter uses weaving, it still adds some overhead. If you don't believe me, go take a look at the examples in the SVN repository (one of them is a simple benchmark). The overhead comes (mainly) from the deserialization of the attributes (aka aspects) applied to each method at runtime (however this is only done once and is still faster than some of the other solutions I've seen).
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
There is a dependency between enhanced assemblies and PostSharp public assemblies. These define the interfaces to be implemented by aspect. There is a dependency from these enhanced code to these interfaces (which can then be merged into the enhanced assembly using ILMerge).
But it is not true that PostSharp Laos has no runtime memory overhead. Indeed, every aspect is an object. If you apply an aspect to 100 methods, you will have 100 aspect instances. So there is some static memory overhead. There is also a dynamic overhead: when an aspect is invoked, memory is allocated for the "event args" object (for instance MethodExecutionEventArgs). Additionally, method arguments are boxed into an array of objects. So this puts pressure on garbage collection and explains the performance cost.
In other words, PostSharp Laos introduces overheads (both in terms of memory and performance) because it is not an inlining weaver: aspects are not inlined into code, but are aspect handlers are invoked from code.
Only inlining weavers have no overhead compared to manually-written code. This is the case for instance of Log4PostSharp[^]. Inlining weavers can be developed using PostSharp Core, but it is much more costly (it takes days, not minutes). but sometimes the pain/gain ratio pays off.
There is an academic inlining weaver for .NET. Here is the paper[^].
I think the review here is too hard to other frameworks. It is simply not fair not to consider that PostSharp is not able, under normal circumstances, of runtime weaving. It can strongly play in favor of Spring.NET, Castle or PIAB if aspects defer according to environments. Why should the logging aspect be developed in the production environment in normal time? Isn't it better to turn it on only on demand, when a problem appears in a component? If this use case is important for you, you will probably prefer a "competing" framework. And if you already using Spring or Castle because of IoC, you will find that their AOP solution perfectly fits in the IoC container. Even in AOP, there is no one-size-fits-all solution.
And by the way, I have an AOP talk comparing different AOP frameworks (Spring.NET, Castle, PIAB, PostSharp). The talk has been reviewed by contributors of all projects, so I can state it is fair and objective. I can deliver it to your community if you invite me!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
| And as AspectDNG is also an inlining weaver, this one should deserve a 3 in terms of everhead. | | | | | |