This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using A-D.A.I.C.

 
Prakalp Shrivastava
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To cut the short story long, can anyone please enlighten me on the practical significance/benefits/scenario where I can imagine using Argument-Defined Anonymous Inner Classes.

Also, as I found this concept can be used with both interfaces and classes with the only 'real big' difference being that while implementing interfaces I would need to define all the abstract methods.

Can someone please tell me that there is more to this than meets the eye(atleast at first glance

Cheers,
PK.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let see if Java In General (Intermediate) can help. A-D.A.I.C isn't, I believe, a topic of the SCJP objectives.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do know what anonymous inner classes are, but what does argument-defined mean?
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:
I do know what anonymous inner classes are, but what does argument-defined mean?

You too? Now you know why I dumped it over here
 
Prakalp Shrivastava
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Barry Gaunt:
Let see if Java In General (Intermediate) can help. A-D.A.I.C isn't, I believe, a topic of the SCJP objectives.


Thanks for moving the thread Barry Hopefully I will get some useful pointers here.

Also, Question related to A-D.A.I.C. have been coming in SCJP exams.
 
Prakalp Shrivastava
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:
I do know what anonymous inner classes are, but what does argument-defined mean?


Hi Ilja,
Thanks for replying

At the most basic level, A-D.A.I.C. are just what the name suggests.
They are anonymous implementation of interfaces, defined in the calling methods argument list.

This, seemingly, allows the method to instantiate and use an interface 'object' for otherwise mundane java tasks

In my understanding, this can additionally be spiced up a bit by having subclasses defined in the method argument list as well. Ofcourse, other rules governing anonymous classes apply to this technique like no more than one interface can be implemented etc.

Now, my real doubt is why/what is the exact use of this knowledge(!!) As I see it, this is just like trying to catch the ear from the wrong side.
Any inputs on this wud be highly appreciated.

Cheers,
PK
[ August 04, 2006: Message edited by: Prakalp Shrivastava ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, so the following would be an A-D.A.I.C.



In my experience, ADAICs are most often used as callbacks: http://en.wikipedia.org/wiki/Callback_%28computer_science%29

In fact, as I think about it, most of my AICs are ADAICs...

Does that help?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't recognize the term either (and I don't particularly see why the term even needs to exist). But as Ilja says, it's a common way of doing things once you get the idea of anonymous inner classes. For example:
 
Prakalp Shrivastava
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Danke Ilja for the wiki link
It did clear some ideas in my head regarding callback approach et al. but the concept seems to be more application to C/C++ type languages than any other.

Still doing some more reading on this, and will keep updated if I find something really worth sharing with you all .
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prakalp Shrivastava:
the concept seems to be more application to C/C++ type languages than any other.


In which way?

It's actually a common technique in quite a lot of different languages: OO languages using Strategies/Commands etc. or inbuild language support such as C# delegates or Smalltalks closures; function pointers in procedural languages; etc. pp.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic