I was trying to make an API. I just wanna hide all details from end programmer. I also want to provide them number of options to call a function.For example
I have 4 functions with same name but different signature (overloaded functions)
function1()
function1(arg1)
function1(arg1,arg2)
function1(arg1,arg2,arg3)
In above sequence 4th function ie function1(arg1,arg2,arg3)
is having actual logic. rest functions are calling next function with some default values.
Now ,If a user calls 1st function in above sequence ie function1()
then it is calling 2nd function ie function1(arg1)
with some default values. and so on.
My question is, this sort of chaining is saving LOC(Line of Code) and increasing understanding. But whether it is good as per performance view?
Conditions with me
- I am using Java
- I am using JDK1.4. So variable number of arguments are supported.
Although you can suggest me performance in other languages as well, provided that you are not suggesting "variable number of arguments" feature.