(I originally wrote this blog post in 2012, and it seems like it has held up well over time.)
One great thing I’ve learned from Scala and functional programming over the last few months is this:
Make your variables immutable, unless there’s a good reason not to.
“Immutable” means that you can’t change (mutate) your variables; you mark them as final in Java, or use the val keyword in Scala. More important than you not changing your variables is that other programmers can’t change your variables, and you can’t change theirs.