OOP Framework check

Few minor things:

You don’t need this:

Since you’re already constructing the table here:

You also don’t need this:

Since that’s what your Tween.new does.

Code:

--Attempting to make a framework for tweening ui
local Tween = {}
Tween .__index = Tween

function Tween.new(part, property, startValue, endValue, duration, easingStyle, easingDirection)
	local self = setmetatable({}, Tween)
	self.Part = part
	self.Property = property
	self.StartValue = startValue
	self.EndValue = endValue
	self.Duration = duration
	self.EasingStyle = easingStyle
	self.EasingDirection = easingDirection

	return self
end

function Tween:IncreaseSize(...)--something like this perhaps? or send every property in the template?
	--eg mousehover
end

function Tween:DecreaseSize()--may not be used	
end

function Tween:Rotate()--probably not used (no pets in game, maybe chests)
	--eg pets/chests
end

function Tween:FadeOut()
	--closing inventory screen
end

function Tween:FadeIn()
	--opening inventory screen
end

function Tween:ChangePosition()
	--hiding ui off screen etc
end

return Tween

You also missed some boilerplate like returning the module and setting the .__index, but it looks good so far.

More information if you’re ever stuck: All about Object Oriented Programming

1 Like