I am trying to create an object model for a user and a chatroom. I’m stuck on where to place certain functionality when the objects collaborate.
At the moment all the functionality for the User is inside the User class, a snippet of its methods are:
I recognize that is this is a “God Object”/”Blob”” and instead we could model this as seperate objects ChatRoom, User and Group with the methods:
But I am confused about this refactor since, the way I understand object methods is that they perform an operation on the object. Therefore you can command the user to write to a chatroom, command the user to join a group, etc.
But with the “cleaner” second model this doesn’t seem to fit, there is no explicit
How do I design and think about what methods should be attached to an object?