This is an abstract question to clarify a refactoring concept in the ruby language. Assume in the real world that there would be many more variables and method in the Furniture Class and Refinish method.
I have a Class called Furniture.
It has a method called '
This method has
varnish_cost = Varnish(VarnishToUse).price * TimeToTake
I want to extract out the cost calculation into
def VarnishCost price * TimeToTake end
then the Furniture class can just have:
def Refurnish(VarnishToUse) varnish_cost = VarnishCost(VarnishToUse) end
How do I pass in the VarnishToUse into VarnishCost? Should the method be
def VarnishCost(Varnish) ... end
or should I be setting an instance variable
@varnish = VarnishToUse in the Refinish class and then just expect that instance variable to be available in the VarnishCost method as I showed above? Does it make a difference if the other method is private? protected?
I am looking to minimize the use of variables and multiple responsibilities for a class (SRP).