in reply to Event based programming: Callbacks or "Interfaces"?
OO interfaces might work better if I'm already organizing code in an object-oriented way. Assuming that the way that I want to organize code matches what the API is going to look for.
My personal preference is for callbacks if the API is simple and an OO interface if it is not. But that isn't a strong preference. In fact it is a good exercise to figure out how to make a callback API turn into something that expects an OO interface. (Hint: You may have to assign to typeglobs.) Conversely you can take something that expected an OO interface and have it call methods that were passed into the constructor via callback. (Hint: Store the callbacks in the object.)
|
|---|