Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Roo and aspect-oriented programming

i've been running some experiments of my own with Spring Roo and it seems to be pretty cool, but i noticed that this tool makes heavy use of AOP on the model layer.

I'm thinking about creating a real project using Roo and what i would like to know is:

  • Why AOP is everywhere? Is that ok?
  • What are advantages and disadvantages of this approach?

I'm quite new to aspect-oriented programming and some guidance would be greatly appreciated.

like image 572
marcosbeirigo Avatar asked Jun 15 '10 06:06

marcosbeirigo


People also ask

What is Aspect-Oriented Programming in spring boot?

AOP is a programming paradigm whose main aim is to increase modularity by allowing the separation of cross-cutting concerns. AOP does this by adding additional behavior to the existing code without modifying the code itself. It provides functionalities to add new code and behavior separately.

Is Spring Framework aspect-oriented?

Aspect-Oriented Programming (AOP) is one of the key elements of the Spring Framework. AOP praises Object-Oriented Programming in such a way that it also provides modularity. But the key point of modularity is the aspect than the class. AOP breaks the program logic into separate parts called concerns.

What is the difference between Spring Aspect-Oriented Programming AOP and AspectJ AOP?

Spring AOP and AspectJ have different goals. Spring AOP aims to provide a simple AOP implementation across Spring IoC to solve the most common problems that programmers face. On the other hand, AspectJ is the original AOP technology which aims to provide complete AOP solution.


1 Answers

The Spring Framework has extensive AOP capabilities, and it makes sense to use these in Roo-based applications. AOP allows you to make a nice and clean separation between business logic and system logic. When done properly, you get a more maintainable and understandable codebase.

The disadvantage is a small performance hit, but not enough of one to make me worry about it.

To learn more about Spring and AOP, have a look at the docs. Spring uses AOP for things like transaction management and asynchronous operations.

edit: As @chedine rightly pointed out, the AOP is compile-time weaved, so the usual AOP performance hit does not apply.

like image 130
skaffman Avatar answered Oct 16 '22 18:10

skaffman