One
Aspect is the modularity of non-business functions that can recur in different places in the application, such as logs, transactions, security, caching
In software development, functions. span multiple points of an application is
Called cross-cutting concerns. Typically, these cross-cutting concerns is conceptually
Separate from (but often embedded directly within) the application ' s business logic.
Separating these cross-cutting concerns from the business logic is where aspect-
Oriented programming (AOP) goes to work.
DI helps decouple application objects from
Each of the other, AOP helps decouple cross-cutting concerns from the objects they
Affect.
Logging is a common example of the application of aspects, but it's not the only
Thing aspects is good for. Throughout this book and you'll see several practical applica-
tions of aspects, including declarative transactions, security, and caching.
aspects help to modularize cross-cutting concerns. In short, a cross-
cutting concern can be described as any functionality, affects multiple points of an
application. Security, for example, was a cross-cutting concern, in this many methods in
An application can has security rules applied to them. Figure 4.1 gives a visual depic-
tion of cross-cutting concerns.
This is represents a typical application that's broken down into modules.
Each module ' s main concern are to provide services for their particular domain. but each
module also requires similar ancillary functionality, such as security and transaction
Management.
A Common object-oriented technique
For reusing common functionality are to
Apply inheritance or delegation. But inheri-
Tance can leads to a brittle object hierarchy
if the same base class is used throughout an
application, and delegation can be cumber-
some because complicated calls to the dele-
Gate object may be required.
aspects offer a alternative to inheri-
tance and delegation that can is cleaner in
many circumstances. With AOP, you still
define the common functionality in one
Place , but can declaratively define how and where this functionality is applied
without has to modify the class to which you ' re applying the new feature. cross-
cutting concerns can now is modularized into special classes called aspects. this have
The benefits. First, the logic for each concern are in one place, as opposed to being scat-
tered all over the code base. Second, your service modules is cleaner because they
Only contain code for their primary concern (or core functionality), and secondary
concerns has been moved to aspects.
SPRING in ACTION 4th Edition notes-fourth chapter aspect-oriented spring-001-what is AOP