Re: Event binding/this problem
Ian Petersen <[email protected]>
| Newsgroups | gmane.comp.web.dom.wdf |
|---|---|
| Message-ID | <[email protected]> |
I think the biggest concern with global variables is that they become "hidden state". Ideally a function's output only depends in its input (its arguments). If you have global variables, then all of a sudden they become hidden inputs to every function. Then your code becomes harder to maintain because you don't (necessarily) know what the consequences are of modifying a global (either by changing its value at run-time or by renaming it to better suit its intended use). This problem is also related to tight coupling. If two, otherwise unrelated, functions use the same global variable, then they suddenly are coupled. The more globals in use, the more tightly coupled they become. What happens if you call function A before function B? How about the other way around? They share some state through the global variable and thus you have to consider each function's impact on the other. Tight coupling is one of those things you should try to avoid unless you have some good reason not to. As far as memory leaks are concerned, I suppose it could be a problem. Global variables tend to be long-lived, so if they also take up lots of space, then I guess they would introduce memory issues. Ian -- Tired of pop-ups, security holes, and spyware? Try Firefox: http://www.getfirefox.com ------------------------ Yahoo! Groups Sponsor --------------------~--> Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/9rHolB/TM --------------------------------------------------------------------~-> Unsubscribe [email protected] List info http://www.quirksmode.org/dom/list.html Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/wdf-dom/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/