Where case classes should NOT be used in Scala? -


Scale is the case class standard class which is enhanced with pattern-matching, equal, ... (or is i wrong?).

Apart from this, they do not need any new "new" keywords for their instanciation, I think they are simple to define compared to regular classes (or am I wrong again?).

There are many web pages in it that how they should be used (mostly about pattern matching). But where should they be avoided? Why do not we use them everywhere?

There are several places where the case classes are not enough: / P>

  • when Wants to hide any data structure.
  • A type of two or more levels as part of the hierarchy.
  • When the constructor is required special consideration.
  • When Extractor requires special consideration.
  • When similarity and hash codes require special consideration.

Sometimes these requirements appear late in the design, and one needs to change a case class in a general class. Since the benefits of a case class are not really great at all - they have been specially done separately from different special cases - my recommendation to make any case class not As long as you use it clearly.

Or, in other words, do not exaggerate.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -