The latest Scala Times newsletter included this link to an article called 
Effective Scala Case Patterns:

Article: Effective Scala Case Class Patterns - The guide I wished I had read 
years ago when starting my Scala journey 
(github.com)<https://gist.github.com/chaotic3quilibrium/58e78a2e21ce43bfe0042bbfbb93e7dc>

The article criticizes the default case class pattern as we use it in Daffodil 
and says adding a companion object to the case class can fix issues such as 
elevated reasoning complexity, poor FP design, future technical debt, and 
security vulnerabilities.  It's interesting reading, but it proposes adding 
extra code that you'd need only if your case classes can be constructed with 
invalid state (the purpose of the companion object is to detect and prevent the 
invalid state before constructing the class class).  However, adding final to 
all case classes to prevent extension confusion may be worthwhile.

John

Reply via email to