AOP Basics

Aspect-oriented programming is a subject that I find very difficult to find. My old textbook on software mentions only briefly (and vaguely), and Wikipedia and various other textbooks / articles that I could find on it give ultra-academic, highly abstract definitions of what it is like to use it, and when to use it. Definitions that I just donโ€™t understand.

My (very poor) understanding of AOP is that there are many aspects of creating a high-quality software system that would not fit neatly into a nice little cohesive package. Some classes, such as Loggers, Validators, DatabaseQueries, etc., will be used throughout your code base and, therefore, will be highly related. Mine (again, bad ) AOP's understanding is that it is linked to best practices for dealing with these types of "universally connected" packages.

Question: Is this true, or am I completely disconnected? If Iโ€™m completely mistaken, can someone please give a brief, explanatory explanation for what AOP is, an example of the so-called aspect, and perhaps even provide a simple code example?

+21
aop
Jan 27 '11 at 17:37
source share
4 answers

Separation of problems is a fundamental principle in software development, there is a classic article by David Parnassus about the criteria that will be used in decomposition systems into modules that can introduce you to the subject, as well as read Uncle Bob's SOLID Principles .

But then there are Cross Cutting problems that can be included in many use cases, such as authentication, authorization, validation, logging, transaction processing, exception handling, caching, etc., which spawn all layers in the software. And if you want to solve the problem without duplication and using the DRY principle, you have to handle it in a complicated way.

You should use declarative programming, which simply in .net could annotate a method or property with an attribute, and what happened later is a change in the behavior of the code at runtime depending on these annotations.

You can find a good chapter on this topic in the Sommerville Software engineering book

Useful links C2 wiki CrossCuttingConcern , MSDN , How to solve cross-link problems in developing development-oriented software

+12
Jan 27 '11 at 17:55
source share

AOP is a method in which we extract and remove cross-cutting problems (logging, exception handling ...) from our code in its own aspect. leaving our original code, focusing only on business logic. not only does this make our code more readable, supported, but also DRY code.

This can be better explained with an example:

Aspect Oriented Programming (AOP) in .net world using Castle Windsor or Aspect Oriented Programming (AOP) in .net world using Unity

+2
Aug 11 '15 at 7:13
source share

AOP deals with cross-cutting issues, that is, things you need to do throughout the application. For example, registration. Suppose you want to track when you enter and exit a method. It is very easy with aspects. Basically, you specify a "handler" for the event, for example, method input. If necessary, you can also specify with the help of "wildcards" which methods are of interest to you, and then it is just a matter of writing handler code, which can, for example, register some information.

0
Jan 27 2018-11-17T00:
source share

Aspect-oriented programming basically consists in separating cross-cutting issues (non-functional) and developing it as aspects such as security, logging, monitoring, etc., keeping it aside when you need in your application, you can use it as plug and play. The only advantage we can achieve is clean code, less code and programmers can focus on business logic (the main problems) so that a more advanced system of modularity and quality can be developed.

0
Jan 28 2018-11-11T00:
source share



All Articles