alexandru/scala-best-practices — pull request #13 by leothekim (2014-10-31 15:28:13+00:00)
Title: Add rule 4.12

Saw this on Hacker News. This is a great collection of rules! I added a rule about the behavior of lazy vals declared in functions, which has bit us in the butt a while back. Though declaring lazy vals in functions is allowed by scala, the behavior we assumed was that the lazy val would use a locally scoped lock. Instead, it uses an object-instance lock. Not only is using a lazy val in a function a little smelly, but it can result in an unexpected concurrency bottleneck.