Hacker News new | ask | show | jobs
by ilaksh 4471 days ago
Hm. Forget I mentioned the term "global variable" since it is a religious term.

I am not trying to argue against proper encapsulation and coupling/decoupling. Those things are great. Classes and modules and great. Not sure how you see me as attacking those things.

Say I am working on a web application and I want to use AJAX. I should not have to keep saying in every place that I want to use it "oh by the way I am using AJAX".

If you agree with this then exactly what sort of encapsulation and coupling would you recommend for the overall application to achieve not having to keep saying that it wants to use AJAX?

1 comments

I think you should basically say "oh by the way I am using AJAX", whether that means using Angular-style DI or require or a mixin some other means. In a language with a built-in concept of modules, you'd have to import or include something like that, wouldn't you?

There are some practical benefits, aside from the general happiness provided by namespacing. Not that every single app needs this, but it's pretty handy for example to be able to substitute a mock AJAX service for testing and offline development purposes.