Functional versus Object-Oriented: help me understand the purpose of it all

All of that is correct, yes.

In terms of why you shouldn’t use _G or shared thats mostly because it’s bad practice to store things in a global environment. The more that’s there, the more likely it is something will be overwritten or overlooked. That being said there’s no real functional difference between storing something in modules versus those tables. Modules are just self-contained.

The metatables in this case come into play because it’s easier than manually defining references to every function in a class. Otherwise they’re unnecessary.

Super and subclasses can be done in a variety of ways but I prefer iterating through all of the members of the superclass to add them to the subclass. If you use next it can be done with very little performance issues.

Circular module requiring shouldn’t be an issue in a proper class system. It’ll be purely hierarchical so cross requiring should be easily avoidable.

An easy way to tell what can and cannot be used multiple times is to check what if you need to modify a function or table, or if it relies upon internal script variables to function or not. If the answer to either of those is yes you should probably just put it in your normal script.

3 Likes