Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing around state seems strange #2

Open
pdincau opened this issue May 16, 2016 · 1 comment
Open

passing around state seems strange #2

pdincau opened this issue May 16, 2016 · 1 comment

Comments

@pdincau
Copy link
Contributor

pdincau commented May 16, 2016

example:

https://github.com/mobos/mob/blob/master/apps/mob/src/mob.erl#L124-L134

why do you pass around state? probably you can extract from the state the variable you need in the previous function.

Benefits:

  • clearer function
  • you don't have to return a state that is the same as before
@0xNaN
Copy link
Contributor

0xNaN commented May 21, 2016

Yes, I understand your point and I agree.
I remember I was trying to find a way to test a gen_server without caring too much about the OTP details: so to test a "deploy" I ended up to test handle_deploy(Service, State) rather than handle_call({deploy, Service}, From, State) in which there is noise of the OTP framework (think abuout From) and the operation has to be understood from the real message sent rather than the function name. Obviously a test should be done in a certain state and could operate on the state itself, here the strange state passing.

Anyway I agree that is less clear and not the correct approach, I've tagged the issue as refactoring 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants