Re:Why I Don’t Regret Moving Our Android App to Scala
by curun1r on Thursday July 13, 2017 @01:00AM
(#14758848)
I forget who said it, but there's a quote along the lines of, "There's no problem in programming that can't be solved by adding another layer of indirection. Getters are just that, a layer of indirection. So they give you a hook to intercept a call and do something that wouldn't be possible with direct field access. Perhaps you want to lazy-load the field, or dynamically compute its value under certain circumstances. Whatever it is, if you use getters from the outset, you won't have to change code that calls the getters when you decide you need that indirection.
[ Parent
| on HN ]
Re:Why I Don’t Regret Moving Our Android App to Scala
by saghm on Thursday July 13, 2017 @11:24AM
(#14762055)
Fair enough, although those types of things seem like they'd need to be explicitly written, not auto-generated by a compiler (like the ones described as existing for Scala)
Re:Why I Don’t Regret Moving Our Android App to Scala
by simon_o on Thursday July 13, 2017 @12:13PM
(#14762534)
That's the whole point of what Scala is doing.
Allow flexibility to support such requirements later on, without forcing people to break source and binary compatibility, unlike in Java, C# etc.
That's the reason why you can e. g. implement or override a def with a val.