what is better? one method to return values or many methods
Posted on 2003-12-04
I was wondering what is better to use,
i have a big project with lots of methods and values.
My program currently has method for returning each value, for example.
public int getA()
public int getB()
public int getC()
and i had an idea to make one method to return the value according to a mark.
public static final A = 0,B=1,C=2;
and in the program to have one method for all:
public int getValue(int field)
int returnValue = 0;
case A: returnValue = a;break;
case B: returnValue = b;break;
case C: returnValue = c;break;
same things for objects my class can return when the main class asks for it.
What is better with preformance, and is right to do?