Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:30:21+00:00 2026-05-25T13:30:21+00:00

I first thought about using ITDs to define the private static final Logger logger

  • 0

I first thought about using ITDs to define the private static final Logger logger = ... for some unrelated cases, but it doesn’t look enough like an obvious improvement to use that as a demonstration example.

Is there some standard/suggested example of ITD usage, which people should use for teaching purposes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:30:22+00:00Added an answer on May 25, 2026 at 1:30 pm

    I’d like to add another example to Adam’s answer.

    Using aspects is a way to improve modularization of your software, as well as OOP is, except that OOP is applied “vertically”, while AOP is applied “horizontally”.

    So, while advice can be used to modify “horizontally” the behavior of all methods responding to some criteria, aften code in advice will need also some data, and ITD makes it possible to add that fields “horizontally” while at the same time contain in a single compilation unit (the aspect) related data and code.

    Since you are adding data via ITD fields, you’ll probably also want to offer some method to manipulate those fields, like a setter/getter.

    I tried to rephrase it a few times, I hope it’s easy to understand.

    To give you an example, suppose you have a graphical editing program, where the user can create, delete and display a number of Shapes (pretty canonical eh? 😀 ).

    Shapes have a lot of data, for example they have a color, coordinates etc.. which correctly belong to the class itself. However, since this is a web 3.0 application, you want users to be able to cooperate on a single drawing, which means each shape must know when it is changed, if it has been communicated to other users that the shape is changed, wether it is locked by some user that is actually dragging it etc..

    You can do it in simple OOP, implementing relevant parts in Shape or whatever your root class is, but you will the pollute all your setters with calls like “this.setDirty(true)” or similar stuff.

    Instead, you decide to go AOP and implement it in an aspect. In this case, you can easily add an advice after all setters, but you’ll also need to store a “dirty” boolean, or even a list of properties that changed if you want to optimize your network protocol sending only deltas of changes.

    You could implement it like

    public aspect ShapesAreDirtyThings {
    
       private boolean Shape.dirty;
    
       after(Shape s) : execution(* Shape+.set*(..)) {
           s.dirty = true;
           // Set some other global field, start a thread to communicate 
           // to other users about the change, whatever .. 
       } 
    
       public boolean Shape.isDirty() {
           return s.dirty;
       }
    
       public boolean Shape.findDirtyChildren() { // whatever
    } 
    

    This is nothing you cannot do with common AOP, is simply a matter of encapsulating in a single compilation unit advice, data needed by that advice, and methods that will eventually operate on that data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We look to build a high-performance, scalable Comet server, and thought first about using
We look to build a high-performance, scalable Comet server, and thought first about using
Okay at first I thought this would be pretty straightforward. But I can't think
here's the main code at first I thought is was the message box but
I'm using $lang=$_SERVER['HTTP_ACCEPT_LANGUAGE']; to detect the language of the browser. At first, I thought
What is the reason null doesn't evaluate to false in conditionals? I first thought
For a new Java web project I thought about using: Eclipse as IDE Mercurial
I'm having this argument about using Cursors in TSQL recently... First of all, I'm
does the following integer arithmetic property hold? (m/n)/l == m/(n*l) At first I thought
Ok first of all, the unicorn avatars are hilarious. Seriously, I thought my account

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.