Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

AJAX Callback - Design Patterns

This is looking messy!



7:19 pm on Dec 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I'm not use to this whole callback methodology and if I keep going at this rate - I'm going to end up with a ton of spaghetti code!

General OO practice would dictate creation of discreet modular methods and objects that can then be invoked by a shallow wrapper method at the point of execution.

Problem is that all these things like animation sequences and async HTTP calls require waiting for a response and they're all handled *asynchrously* which then dictates a callback action befined within that particular action. So, I am now linked between one method and the next and end up with a whole chain of methods now being dependent upon one another, one after the next (they're no longer discrete and independent). Even worse - I no longer see the value in writing discreet methods this way; I might has well just have one long rambling method per action instead of trying to break up sub tasks as methods.

Is this really how AJAX developers work? Surely not? Can someone please enlighten me as to appropriate design patterns when using async event driven models?



7:39 am on Dec 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I found the solution - it lies in a proper event-driven model. As a background coder primarily, I'm not use to thinking in terms of asynchronous events and callbacks scenarios. Event drivers appear to be the key to a clean coding model...

Featured Threads

Hot Threads This Week

Hot Threads This Month