Refactoring a function

Hi,
I have the following method :
//Here IdForAuth will be a userId who is member of the channelID so using its token
one can fetch the details of the channel
public Channel fetchChannelDetailsFromChannelId(String channelId, String IdForAuth) {
token = fetchToken(idForAuth)
Channels.getInfo(token, channelD);
}

Now is the signature for above method is fine.
Or could i do like fetchChannelDEtailsFromChannelId(String, String token) and directly use token
inside..

Please suggest your view about both ways

thanks
Rohit BajajAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
Will go with Method1.

Handle fetchToken in method itself.
0
girionisCommented:
It depends on the design of the application and what the token is/where the token is used.

In the first case the token is local to the method (assuming that the token is not an instance variable) and it is only used internally to that method.
In the second case the token is obtained elsewhere and is used in the method.

Use the first case if you do not need to use the token anywhere else.
Use the second method if the token needs to be used in any other methods as well.

If the token is an instance variable and you need to initialise it right before obtaining channel details, then use the first case.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.