Let's say we have a class with 3 class variables and function funA
which calls another funB
, while funB
uses all 3 class declared variables.
So my question is should the funB
reference variables from it's body, like this (pseudo-code):
class A{
var var1 = ...
var var2 = ...
var var3 = ...
funA(){
funB()
}
funB(){
// lets say we just multiply the values and store a result somewhere
var result = var1 * var2 * var3
...
}
}
or like this:
class A{
var var1 = ...
var var2 = ...
var var3 = ...
funA(){
funB(var1, var2, var3)
}
funB(var1, var2, var3){
// lets say we just multiply the values and store a result somewhere
var result = var1 * var2 * var3
...
}
}
What is the best practice? Is it dependent on the language? Thanks in advance!
If the second way is no added value, i would prefer the first way.