What's wrong with anonymous functions?

@ArkDG: If you look at previous examples there are far better ways to do it. Like:

Code:
TDD_Example = {}; // Makes an empty object(function($) {  // All your plugin code goes into this anonymous function  $.myPublicFunction = function() {}; // Binds myPublicFunction to TDD_Example, so it can be accessed with TDD_Example.myPublicFunction()})(TDD_Example); // Here we pass in TDD_Example as the value $ will get inside the enclosure.
Noob question, when and only when should we use that function with the $ thing?
Noob question, when and only when should we use that function with the $ thing?

I would suggest you don't at all. These specific functions like $gameBla or $dataX are the way MV has done things but if you look they are just calls to classes or static classes, Just create a static class or object and assign getters (and/or setters) to it and make that public.
$ is just a variable name, like anything else. It originates from jQuery/Prototype (i think) and usually is used to mark a "context" the function is run in. In Galenemereth's example, you could write "TDD_Example" everytime, but it's easier to just pass it to the function and use the short name, instead.


It also makes it easier to rename the module, afterwards, sind you only need to change it at 2 positions, and not everywhere.
I kind of want to make a core script module. How would you give me a proper example or a way to do it, that stores my variables very well? I know it kinda sound off with the original topic, but any help would really be nice.

Original thread: https://forums.rpgmakerweb.com/threads/whats-wrong-with-anonymous-functions.52016/