Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 534 Bytes

Factory Method.md

File metadata and controls

12 lines (9 loc) · 534 Bytes

#tag

Using 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