Factory Method
by:
cyrus01337Using classes with metatables ends up being problematic for several reasons:
- No standard way to define a class
- Lack of support due to complexity of metatables
- Lack of type-safety and autocomplete (without bending over backwards)
Enter the factory method where you create functions that create and manipulate typed objects. This approach:
- Doesn’t impact support as you’re working with dictionaries
- Provides the type-safety and autocomplete you deserve
Example here