Aspect-oriented programming

AOP is a programming paradigm that allows us to separate business logic from some technical code that crosscuts all applications. In other words, AOP allows the separation of crosscutting concerns. We will encounter crosscutting code when we input the logging code in certain methods to show technical support information. We also encounter it when we input statistic code to see how many times a method calls or who the user using the application is, or even for exception and error handling. We see this kind of code in almost all parts of an application—it is code that is repeated along the whole application. This kind of code has its own objectives and concerns, and it is a very good idea to separate it from the business code, which is related to the application use cases.

These aspects of the system (such as logging or exception handling) are very difficult to implement in a modular way. What we are saying here is that we don't want to mix these aspects with business code. By mixing these two types of code, we are left with a final code that is more difficult to maintain.

With AOP, we can join or add an executable code to our source code without changing it, meaning that the source code remains intact. As we said, if we want to log a method, for instance, then we can do that without disrupting our business code with a service code, such as the logging service.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.254.118