Conversation
|
Thanks, @0000marcell for your contribution! 🎉 I'm glad to see the first feature made by another contributor! 👏 |
|
|
||
| class Client | ||
| attr_reader :address, :net_http | ||
| attr_accessor :address |
There was a problem hiding this comment.
This little change affects the immutability principle because you are mutating the object state.
Look this http://dustinzeisler.com/refactoring/2017/12/11/refactor-towards-immutable-objects-ruby.html article/video to see how do you can achieve the same result keeping an immutable operation.
| attr_reader :net_http, :map | ||
|
|
||
| Map = -> (client, path) { | ||
| client.clone.tap { |c| c.address = BuildURL.(c.address, path) } |
There was a problem hiding this comment.
Avoid the usage of a setter, building a new object.
Related to the previous comment.
|
Thx for the feedback and resource, i'm still not sure if that's the best approach, i'm not very familiar with fp, learning as i go, one thing that i've wished we could do is to map by other param, like port or anything else really, using the same Map, does that make sense ? something like I know that this syntax is broken, just trying to communicate the idea |
Hi @serradura, learning a lot about functional ruby reading your code, i'm still not sure about the naming question, but i think "map" is just fine, maybe it would be a problem in the future if we wanted to map something else with the client, map the ports for example and create a new client based on the port, what do you think ?