Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

concep of callback

 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
could anyone give me a clear concept of "callback" associating this in a realworld context? there is a callback interface in SAX so i would like to get a clear idea of this callback before getting into these interface.
thanks.
himal
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the word "callback" refers to the notification mechanism. When we say the following -
xmlReader.setContentHandler()
xmlReader.setErrorHandler(), etc.,
what it means is that we are registering with the xmlReader parser to receive callback(notification) about the events that happen when the parser parses the xml document. I guess this is a brief explanation of what exactly happens.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'XML in a nutshell' explains the concept in the following way -
The SAX API is unique among XML APIs because it's an event-based push model rather than a tree-based pull model. As the XML parser reads an XML document, it sends your program information from the document in real time. Each time the parser sees a start tag, an end tag, character data, or a processing instruction, it tells your program. You do not have to wait for the entire document to be read before acting on the data at the beginning of the document. The document is presented to your program one piece at a time from top to bottom. You can either save the pieces you're interested in until the entire document has been read or process the information as soon as you receive it....

You need to look closely at some examples to grasp this beautiful mechanism.
Cheers,
Dan
[ October 09, 2002: Message edited by: Dan Drillich ]
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your alarm clock is a real world callback methods you set. When preset time arrives, it calls you back and wakes you up.
I originally learned callback from c/c++. You pass a (callback) function pointer to the method. When something happens, the function is called.
The same concept is used by Java EventListener, Swing Timer. SAX is another use of it.
In GoF design pattern terminology, it is called Observer/Observable design pattern, or Publisher/Subscriber design pattern.
Happy learning!
 
Jane Somerfield
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In client-server system, callback means that
server calls the client.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic