Logo with title ".Blog"

Dependency constants

Published on

Using constants instead of literals in certain cases will reveal dependencies you didn’t know you had.

-- Bad: literals.
local things = require(Things)
RegisterThing("foo", things.FooThing)
RegisterThing("bar", things.BarThing)

local foo = GetThing("foo")
local bar = GetThing("bar")



-- Good: constants.
local things = require(Things)
RegisterThing(things.Foo, things.FooThing)
RegisterThing(things.Bar, things.BarThing)

local foo = GetThing(things.Foo)
local bar = GetThing(things.Bar)