juan_gandhi: (Default)
[personal profile] juan_gandhi

if your class is not a function of its constructor parameters (like, e.g., case class is), don't introduce these parameters at all. Make them members. Use a factory to build your class.

Then you can turn them into traits, and compose them freely. That's just one advantage.

The other advantage is that you won't need to reassign parameter values to members that are already declared in traits.

In short, careful with constructors. You may not need them. Scala is not C++, you know. 

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 1920 21
222324252627 28
29 30     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 3rd, 2025 11:37 pm
Powered by Dreamwidth Studios