homepage Welcome to WebmasterWorld Guest from 50.19.169.37
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
AJAX Callback - Design Patterns
This is looking messy!
cabbagehead




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

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?

Thanks!

 

cabbagehead




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

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...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved