alexandru / scala-best-practices

A collection of Scala best practices
4.39k stars 623 forks source link

Add a rule: case classes SHOULD be final #55

Closed jordanobodh closed 6 years ago

jordanobodh commented 6 years ago

As extending a case class would lead to unexpected behaviour, a rule should be added that case classes should be final. Why case classes should be final

speedcom commented 6 years ago

Why case classes are not final by default in Scala?

alexandru commented 6 years ago

There are certain instances in which you want to override the methods of a case class.

Very rare. And it's not worth it. They should have been final.

alexandru commented 6 years ago

If anybody wants to add the rule, I'll merge it.

kusumakarb commented 6 years ago

I'll submit the PR.