| « Thanks, Sponsors! | The Investment Experts » |
"After our UI developer left," Danny writes, "I was tasked with figuring out why one of our admin pages would get stuck in the middle of the loading screen."
"I know creating named functions for every callback can be a pain, but this a little ridiculous...
eventManager.addDelegate(LOAD_COMPLETE,
new FunctionDelegate(
function() {
eventManager.addDelegate(LOAD_COMPLETE,
new FunctionDelegate(
function() {
eventManager.addDelegate(LOAD_COMPLETE,
new FunctionDelegate(
function() {
eventManager.addDelegate(LOAD_COMPLETE,
new FunctionDelegate(
function() {
eventManager.addDelegate(LOAD_COMPLETE,
new FunctionDelegate(
function() {
eventManager.addDelegate(LOAD_COMPLETE,
new FunctionDelegate(
function() {
eventManager.addDelegate(LOOKUP_COMPLETE,
new FunctionDelegate(
function() {
PopupDisablePanel.hidePopup();
renderLanguageFields();
refreshDirectoryTables();
Field.activate("macAddress_0");
}
)
);
PopupDisablePanel.setPopupText("Loading Language Info...");
loadLanguageInfo();
}
)
);
PopupDisablePanel.setPopupText("Loading Directory Entries...");
loadDirectoryData();
}
)
);
loadLineAccountData();
}
)
);
if (macAddress.length > 0) {
PopupDisablePanel.setPopupText(Loading Config Data...");
loadConfigData();
}
else {
checkCreateConfigValid();
PopupDisablePanel.setPopupText("Loading User Data...");
loadUserData();
}
}
)
);
loadStatusGroupData();
}
)
);
loadExistingUserMacData();
}
)
);
Re: A Bit of Closure
2008-07-28 09:28
•
by
Waffle
(unregistered)
|
|
|
Twenty-two levels of nesting (plus the usual noise around this). That's about twenty too many for this code to be easily understandable. And a net effect of the code "executing in reverse" too. At least we know why the author left: he was faced with maintaining this monstrosity.
|
| « Thanks, Sponsors! | The Investment Experts » |