Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is a callback method?

 
Rahul Jadaun
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a callback method?
 
Rohitt Vermaa
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Callback method is a method intended to be passed as a parameter. The callee can then call the passed method. Callbacks are often used in event handling code. This has nothing to do with SCWCD.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with SCWCD

in fact, see the first question of the filters mock test in HFSJ,
it has a question on it !
 
Tim Lawrence
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am also interested in understanding more about callback methods. Could someone please explain what a "container callback method" is as opposed to an "inline method"? (As Niranjan points out) both of these concepts appear in the answer to the first test question of HFSJ Chapter 13 on filters (pg.700).

"doFilter() is both a callback and an inline method" - what does that mean?

regards

Tim
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rohitt's answer is interesting, but methods cannot be passed as a parameter in Java. That is a feature of some other languages like JavaScript and Ruby.

Searching this forum with the keyword "callback" returns many, many results.

One of my previous answers was here .
 
Joe Harry
Ranch Hand
Posts: 10106
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Method passed as a parameter?? The first time I'm hearing this!
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Method passed as a parameter?? The first time I'm hearing this!


Don't feel bad about it

As Marc says, Java doesn't have this, but other languages do, e.g. C has had this for a long time.

It is of course possible in Java to define an interface that has only a single method, and use that as the callback, which would be pretty close.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The good old days with pointers to functions
Something similar could also be done with Reflection.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic