- Joined
- Jun 27, 2012
- Messages
- 1,316
- Reaction score
- 537
- First Language
- indonesian
this could work as well. Galenmereth use this approach in his mouse system ex.I wouldn't say plugins should be black boxes.
They should be black boxes to people that will be using them and don't need to worry about how it works, but for developers that may need to modify your plugin one way or another, they would need a way to do so.
For example, I don't define anonymous methods.
var TH = TH || {};(function ($) { $.myFunc = function () { // something }})(TH.Namespace);If anyone needed to touch that method later on, they can use
to access it.Now if someone didn't have a way to access myFunc, and they actually wanted to add something to it...well, they'd probably be stuck.Code:TH.Namespace.myFunc
just for me though... as long as the original function before modified is not lost... using anonymous / not is not a problem
is there any benefit on using anonymous function beside not polluting namespace ?
since for polluting... we can add the alias inside:
var EST = EST || {};EST.pluginName = EST.pluginName || {};EST.pluginName.oldGameEnemyOpponentUnit = .........
and we contain our alias in one 'EST' module / container
unless there's other benefit beside that. i might also change to using anonymous if it's really have difference.
