When I was programming in Java, I used to have objects and managers for them. You know, a class (typically singleton), which would hold a collection of objects of a certain class and let to conviniently manage them. Now, in Scala, I am finding myself more and more in the situation, where it is quite tempting to put all that functionality in a companion object and avoid creating the distinct manager object.
It all starts with giving IDs to instances and then... why not having the collection in the companion object? And if the collection is there, why not having all the methods to work with the collection in there? And so, the manager is not needed anymore. However, one pecularity is that the companion object usually has a single name like Car
(not like Cars
or CarManager
which presume plurality), so methods that operate with plurals look weird in their coupled wording with the object name.
I would like to know your opinion on this situation and to know if this approach is preferable over the so-seemed unnecessary bloated manager pattern. Any references to any articles on that would also be appreciated.