A lot of good stuff here.
First Onorio you might be one of the guilty parties but I have discussed with others and managed to come up with reasons to back it up.
Second can I just check, that we all mean the same thing by getter?
I think '
user.name' is using a getter where the '.name' is a getter on the data object
I think 'User.name user' is a module function.
Is that the same as what everyone else is talking about.
Third I agree with validating data at program boundaries. Though I think this is true without the getters issue and without a differentiation between OOP/FP
I wrote bit about value objects in Ruby and a follow up article on protecting the application boundaries.
One fast rule I had in Ruby that has so far held in elixir is never have an invalid representation of any concept within the program core.
It's ruby but immutable so might be of interest.
http://insights.workshop14.io/2015/07/15/value-objects-in-ruby.htmlhttp://insights.workshop14.io/2015/07/23/application-border-control-with-ruby-form-objects.htmlFourth. My suggestion was to use getters on structs no where outside of the module that defines the struct. (there were a few comments about getters everywhere hence I thought worth clarifying)
I also do not use the basic struct creation outside of a few functions again in the same module
user = User.create_representation_by_some_means
name = User.name(user)
# Instead of
name =
user.namethe user variable has a representation of a user. I think that knowing that the representation is a struct is too much knowledge even without any consideration of validation or changing the value of a name.
We might want the create function to return a pid so we get the users current screen name which they can change freely
We might want the create function to return an id and we only look up the name it a list of names when it is asked for.