Nir
07/08/2019, 3:12 PMobject
and companion objects, philosophicallyNir
07/08/2019, 3:13 PMNir
07/08/2019, 3:14 PMLogger
and it's an ordinary, well behaved class, you can then have a global of type Logger
called globalLogger
(never mind details of safe initialization at the moment)Nir
07/08/2019, 3:14 PMNir
07/08/2019, 3:15 PMNir
07/08/2019, 3:15 PMobject globalLogger (..) : Logger
Nir
07/08/2019, 3:16 PMrunjorel
07/08/2019, 3:19 PMNir
07/08/2019, 3:21 PMstatic
just to have functions that are not associated with a specific objectNir
07/08/2019, 3:22 PMNir
07/08/2019, 3:22 PMstreetsofboston
07/08/2019, 3:33 PMstatic
like (companion) objects and functions are not only useful for maintaining a global state.
They can also be used for name-spacing/scoping of functionality.Nir
07/08/2019, 3:36 PMNir
07/08/2019, 3:37 PMkarelpeeters
07/08/2019, 5:06 PMWilhelm Fitzpatrick
07/08/2019, 5:14 PMkarelpeeters
07/08/2019, 5:15 PMNir
07/08/2019, 5:33 PMobject
and companions are basically singleton enabling devices, I can't really imagine using them for anything that doesn't require a singleton.Nir
07/08/2019, 5:34 PMobject
, keep object
itself extremely minimal.