Use objectmay be preferred if you need to add behavior to the field. For instance:
class Foo {
object startDate extends java.util.Date {
def isBusinessDay: Boolean =
}
}
class Bar {
lazy val startDate = new java.util.Date {
def isBusinessDay: Boolean =
}
}
Type foo.startDate- foo.startDate.type, and the method call foo.startDate.isBusinessDaywill be resolved statically.
A type bar.startDate, on the other hand, is a structural type java.util.Date{ def isBusinessDay: Boolean }. Thus, the call bar.startDate.isBusinessDaywill use reflection and carry unnecessary overhead.