--
You received this message because you are subscribed to the Google Groups "scala-debate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-debate...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
the getter/setter argument is the only one i can't follow. you also don't need one if your field is public. what's better about the scala version of doing it?
On Friday, February 19, 2016 at 12:36:15 PM UTC-8, Dennis Haupt wrote:the getter/setter argument is the only one i can't follow. you also don't need one if your field is public. what's better about the scala version of doing it?In Java you need explicit getters and setters if you want to keep the interface separate from the implementation, which is considered good practice in general. Suppose I have a public field that I later decide needs to be computed in a method. In Java, without getters/setters I have to force callers/clients to change their code just because my implementation changed (but not the interface). That's not good. Had I used getters and setters I would not have that problem, but they are a nuisance to read/write, and they clutter the code. Scala automatically generates them under the hood so you don't need to write them, and your code stays leaner and cleaner. This should not be confused with an IDE that writes them for you but still clutters your code with them. That's my understanding anyway.
I think the term is "uniform access principle."
I think the term is "uniform access principle."
the getter/setter argument is the only one i can't follow. you also don't need one if your field is public. what's better about the scala version of doing it?