#Not Understanding the purpose of ModuleLoaders and how they work
1 messages · Page 1 of 1 (latest)
There are only really 2 benefits i see in using them
The first one is that you only need to require 1 module to access them all but I don't see a problem in requiring more cause your probably gonna define each module anyway after requiring.
The second one is you can put the require in a pcall to prevent yourself from using broken modules.
another benefit is just readability
once ur game gets to scale the first 50 lines will just be requiring and the next will be initiating
and the fact that you can load certain modules first before others
assuming youre using SSA (single script architecture)
MSA doesnt need a loader as much as they kinda just use one module or two per script
tldr; readability, more safety (can wrap in pcalls like the guy said above and can load in order if one module depends on another)
one BIG con however is you lose the autocompletion (at least with the module loaders ive seen)
i only use them for the init
yeah the auto complete is pretty ass
it's exactly what the name suggests: it loads modules
and the point of them is exactly what the name suggests: they are modules
a module is a building block, a piece of a puzzle
at some point the event-oriented nature of studio becomes annoying and you want to have util functions that you can call between different scripts
but then it becomes annoying because you don't know what gets called or who calls it and having util functions like "getData" in a random util module in replicatedstorage feels off
that's why the single-responsibility principle comes in
each script should be a module because it allows you to still run code whileletting you group util functions together
that way instead of ScriptA and ScriptB requiring DataUtil for GetData
you can have DataService and InventoryService where InventoryService requires DataService for GetData
and then youll easily be able to split different systems into different modules to keep the single-responsibility principle