You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The manner in which objects are constructed isn't entirely consistent at the moment. The most "Kotlin" approach is a bit of a question mark though and certainly worthy of discussion.
We have classes like Duration and Period, which do construction like so:
val duration = durationOf(5.seconds, 5.nanoseconds)
val period = periodOf(2.years, 3.days)
This reads nicely and feels natural enough with the "of", though such syntax tends to be used with list arguments.
Then we have classes like Date or DateTime that use regular constructors or constructor functions that start with capitals.
val date =Date(2019, Month.May, 5)
val dateTime =DateTime(2019, 5, 5, 13, 0)
Then we have Time, which uses invoke() on the companion object so that it can do some object pooling prior to actual construction, making it a bit weird. Companion invokes all need to go, but what is the right construction method? timeOf()? But then should all of the date-time representations use a similar style? What makes for the best syntax here?
The text was updated successfully, but these errors were encountered:
The manner in which objects are constructed isn't entirely consistent at the moment. The most "Kotlin" approach is a bit of a question mark though and certainly worthy of discussion.
We have classes like Duration and Period, which do construction like so:
This reads nicely and feels natural enough with the "of", though such syntax tends to be used with list arguments.
Then we have classes like Date or DateTime that use regular constructors or constructor functions that start with capitals.
Then we have
Time
, which usesinvoke()
on the companion object so that it can do some object pooling prior to actual construction, making it a bit weird. Companion invokes all need to go, but what is the right construction method?timeOf()
? But then should all of the date-time representations use a similar style? What makes for the best syntax here?The text was updated successfully, but these errors were encountered: