I have some huge classes of more than 2k lines of code (and growing) that I would like to refactor if possible, to have some more light and clean design.
The reason it is so big is mainly because these classes handle a set of maps that most methods need to access, and methods are very connected to each other.
I will give a very concrete example: I have a class called Server
that handles incoming messages.
It has methods like joinChatroom
, searchUsers
, sendPrivateMessage
, etc.
All of these methods manipulate the maps such as users
, chatrooms
, servers
, ...
Maybe it would be nice if I could have a class handling messages concerning Chatrooms, another handling all about Users, etc.
but the main problem here is that I need to use all of the maps in most of the methods.
That's why for now they are all sticked in the Server
class as they all rely on these common maps and the methods are very connected to each other.
I would need to create a class Chatrooms, but with a reference to each of the other objects. A class users again with a reference to all the other objects, etc.
I feel like I would be doing something wrong.