Package object for one-liner Scala classes -


This is more of a readability / maintenance question than a technical and a design.

Occasionally at Scala, you get these liner squares (often case classes), which are usually used to keep the data. They are very synonymous with Java beans, but in reality the val members with constructor parameters do not need setter methods due to stability, and due to the need for toString Not a good case-class feature, you end up with just one line of constructor criteria.

I find it worthless to put these one-liners in a different skala file, and I have more muscle scalp classes because it is confusing (even in IntelliJ IDEA This project starts the source pollution of trees)

I have started a new habit of applying these single liners to the package object package.scala in this package. Is there any disadvantage from its responsive approach? I am putting them there for the lack of better place. Is there a better view?

I do not think that adverse / in it, but it also urges me There is no reason to profit or do so.

You may have a look at Basically, if you use the -Xlint compiler flag, you will be told that you do not want not sections Should be put in a package object.

If you want to keep multiple classes together for your one-line nature, you can put them together in one file, this package is not an object.

FooUtil () ...}


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -