To just clear up any confusion
-
The Global Module, Plugin and Library does not have any circular dependencies within them
-
The Global Framework does not force you to have circular dependencies but gives you the freedom to choose if you want them or not
For anyone that does not know what a circular dependency is here is a example
lets Imagen your making a minecraft style game and you have 2 objects/classes world
and block
-- WorldModule
local Block = require(BlockModule)
local World = {}
local blocks = {}
function World:SetBlock(blockType, x, y, z)
blocks[x][y][z] = Block.new(blockType, x, y, z)
end
return World
-- BlockModule
local Block = {}
function Block.new(blockType, x, y, z)
local block = {}
block.Type = blockType
block.X = x
block.Y = y
block.Z = z
return block
end
return Block
Now at this time World requires Block but Block does not require World so there currently not cyclic but you might notice that even though we have no cyclic dependencies these 2 modules are highly coupled together World does not work without Block and Block does nothing without World ok lets now for example add a explode function for blocks and do it in a way that makes it cyclic
-- BlockModule
-- this is a cyclic require
local World = require(WorldModule)
local Block = {}
function Block.new(blockType, x, y, z)
local block = {}
block.Type = blockType
block.X = x
block.Y = y
block.Z = z
return block
end
function Block:Explode()
for x = -1, 1 do
for y = -1, 1 do
for z = -1, 1 do
World:SetBlock("Air", self.X + x, self.Y + y, self.Z + z)
end
end
end
end
return Block
Now world and block are cyclic they require each other
Some people might say this is bad some might not but the good thing about this framework it gives you the freedom to choose