I have a Java class that contains 1756 lines (obviously it's not all code, there are blank lines, lots of comments and some commented code in case you need it in the future)
I'm implementing the MVC
structure and this class belongs to the control.
This class is responsible for:
- manage clients (communicate with clients, save who is connected, send information to them, know who left, etc.)
- fetch data from a webservice and a database (synchronously)
- Process this data and send this information to clients
- Save important data information in the system database
Class structure ServidorService
:
//variaveis
+ 8 variaveis
+ de 12 HashMap //quase todos os dados estão relacionados key->value ex: clientex->outputx
//classes
Problem
The class is getting really big even for me, but thinking about the future of someone needing to change some function I think it will be difficult for her to maintain her code.
What is the best way to refactor it?
Top questions:
-
I want to create a new class,
-
I have tried to create another classes to support the main (ServerService) but I was having problems accessing the variables, what better way to make the other class have access to the variables? through gets?