• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Using A-D.A.I.C.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 28372
99
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Space pants. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic