WPAFC / afch

Yet another Articles for creation helper script -- ACTIVE DEVELOPMENT NO LONGER HAPPENS IN THIS REPOSITORY AND HAS MOVED TO
https://github.com/WPAFC/afch-rewrite
9 stars 3 forks source link

use anonymous functions #188

Closed wikipedia-mabdul closed 11 years ago

wikipedia-mabdul commented 11 years ago

see code of https://en.wikipedia.org/wiki/User:PleaseStand/segregate-refs.js


// Begin encapsulation (prevent interference with other scripts)
(function(){

that is a really good idea I think. ;-)

theopolisme commented 11 years ago

Yes, it's been on my bucket list for a while.

(function($, mw) {
// Code
}(jQuery, mediaWiki));
theopolisme commented 11 years ago

REVERTED -- this caused global variables in core.js to not be accessible to the other branches of the scripts. So the encapsulation appears to be a BAD thing for our multi-file script... i'm inclined to actually WONTFIX this now, since interplay between different .js files is critical to the script.

wikipedia-mabdul commented 11 years ago

then, well, let us change the variable names (and function names, etc) using a prefix "afch_" (or so).

theopolisme commented 11 years ago

I don't think you understand...at all.... that's not what the problem is.

http://stackoverflow.com/a/1643340/1934901

It makes the variables not global between files. Bad.

wikipedia-mabdul commented 11 years ago

sry, I mean that, if we can't capsule the code within a function, we shouldn't do it and we should use a prefix for EVERYTHING (esp. variables)

theopolisme commented 11 years ago

oops.

theopolisme commented 11 years ago

WONFIX as we are currently a multifile global-loving project. Bad us.

/ perhaps a window.afch namespace? /