9

I am new to Spring and I want to clarify something about it. I developed an application for student management, for private institutes. It can record student details (address, phone number, enrolled courses, grade etc...), course details, payments from students, report generating module, details about lectures etc.,

However, I didn't use much of AOP to develop this app, except for rare cases like logging. But Spring AOP is a big part in Spring according to my knowledge. My question is, is AOP a big part of spring or am I missing the places where I should have used it (I am guessing I made newbie mistake of not using AOP much)? If so, can you clarify me where I should have used these concepts, so that I can learn from my mistake.

lahiru madhumal
  • 1,185
  • 2
  • 12
  • 30
  • 3
    For some use general use case of AOP (or AspectJ) you can have a look at this question: http://stackoverflow.com/questions/4313789/what-is-aspectj-good-for -- maybe it helps you to understand where AOP is useful and where not – Ralph Sep 21 '12 at 10:00

4 Answers4

8

My view is that AOP is great if you are building a framework (like spring), as it allows the framework to implement cross cutting code that doesn't greatly impact the users of the framework, for example in spring:

@Transactional

This one line of code in a service class invokes significant transaction management functionality.

However, for normal web-apps (for example), custom aspects should be used sparingly because:

Community
  • 1
  • 1
Solubris
  • 3,603
  • 2
  • 22
  • 37
4

I think I've actively used AOP in only a handful of projects over the years. In my work with Spring I use it rarely compared to most of the other Spring features. As such, I'm aware of it and what it can do, but I don't worry that I'm not ticking that particular box.

It's useful to understand what it is, and what it can do for you. However Spring is doing work for you already that leverages this, and you're likely to be using it already without knowing it! Being aware of AOP and how it works is the major issue here. As such, it sounds like you have this covered.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
3

AOP is a big part in Spring according to my knowledge

Yes it is, As you are already using AOP for logging, for better understanding of AOP read here on aop

Basically aop increased you modularity of application by separation of cross-cutting concerns.

such as it helped you lot at the time of transaction management logging etc.

AOP in spring is used:

  1. To provide declarative enterprise services such as declarative transaction management
  2. To allow users to implement custom aspects.

source

For my understanding you can use transaction management in your application. as you are maintaing the records of students, course, fee etc associated with students.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
subodh
  • 6,136
  • 12
  • 51
  • 73
2

Spring AOP used to tracking entire activity of user in large business applications.
More like logging using AOP we can identify user consumed classes and methods and if any error occurs in any method, developers or customer helpers can identify problem soon and can give solution soon than reading log files.

syril
  • 271
  • 1
  • 5
  • 17