Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Aspect-Oriented Programming is used when you have a "Cross-Cutting Concern," something that affects the whole program, and can't be neatly boxed up into an ordinary class. </p> <p>The canonical example of AOP is logging. Your entire application needs logging, but you don't want to new up a logger object every time you want to log something in a class, because that tightly ties your classes to a logger object, and scatters logging code throughout your application.</p> <p>Instead, what you want to do is have a logger class (perhaps a static one, so you don't have to instantiate it), and then have some way to call that class from anywhere. You want to keep it loosely-coupled, so that you can swap out the logger class for a different one, if you want to.</p> <p>There are a number of ways to call a class via AOP. In C#, one way to do it is by using Attributes:</p> <pre><code>[MyLogger()] CallingThisMethodCallsTheLogger(int someParameter) { // Do something with someParameter that has nothing to do with the logger } </code></pre> <p>Another way to call class methods via AOP is to instrument them. This can be done by performing binary rewrite of the class methods, so that they call the AOP method first, and then call the usual method in the usual way. Instrumenting classes could be done, for example, to measure their performance.</p> <blockquote> <p>Standard terminology used in Aspect-oriented programming may include:</p> <ul> <li><p><strong>Cross-cutting concerns:</strong> Even though most classes in an OO model will perform a single, specific function, they often share common, secondary requirements with other classes. </p></li> <li><p><strong>Advice:</strong> This is the additional code that you want to apply to your existing model. In our example, this is the logging code that we want to apply whenever the thread enters or exits a method.</p></li> <li><p><strong>Pointcut:</strong> This is the term given to the point of execution in the application at which cross-cutting concern needs to be applied. In our example, a pointcut is reached when the thread enters a method, and another pointcut is reached when the thread exits the method.</p></li> <li><p><strong>Aspect:</strong> The combination of the pointcut and the advice is termed an aspect. In the example above, we add a logging aspect to our application by defining a pointcut and giving the correct advice.</p></li> </ul> </blockquote> <p><a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming" rel="nofollow">http://en.wikipedia.org/wiki/Aspect-oriented_programming</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload