Rohit Bajaj
asked on
Java file getting too big
HI,
In my java spring application... There are soem files of around 800 lines...
Does that indicate a bad code design.. What are the factors i should consider to shorten the files and split them into two ?
Whats the ideal maximum file length ?
Thanks
In my java spring application... There are soem files of around 800 lines...
Does that indicate a bad code design.. What are the factors i should consider to shorten the files and split them into two ?
Whats the ideal maximum file length ?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For a start I would not have my rest controller so tightly bound to the github endpoint.
I would move all the GitHub integration into a facade which talks to GitHub using oAuth and graphql.
The facade can then be injected into your rest controller and the facade can also be mocked.
I would move all the GitHub integration into a facade which talks to GitHub using oAuth and graphql.
The facade can then be injected into your rest controller and the facade can also be mocked.
ASKER
Hi
I didnt understand that..
Can you give me a pseudocode example of how you will modify the above code...
Also the process function is the only public function used by thr controller.
I was thinking of defining multiple classes
One for each command.. As in the above code the main job is done by the function
Handlecommand which uses lot of switch statements...
Instead i could have a handler like pullhandler, repoHandler....these classes
And forward the processing to them..
This way i can have the code for each of them separately...in various classes.
Please suggest n guide
Thanks
I didnt understand that..
Can you give me a pseudocode example of how you will modify the above code...
Also the process function is the only public function used by thr controller.
I was thinking of defining multiple classes
One for each command.. As in the above code the main job is done by the function
Handlecommand which uses lot of switch statements...
Instead i could have a handler like pullhandler, repoHandler....these classes
And forward the processing to them..
This way i can have the code for each of them separately...in various classes.
Please suggest n guide
Thanks
your project is an integration project.
Your rest controller should talk to a facade class.
The facade glass will then talk to GitHub using graphql. Its just introducing another layer thats all.
Your rest controller should talk to a facade class.
The facade glass will then talk to GitHub using graphql. Its just introducing another layer thats all.
ASKER
I was asking about the java file .. Here is the file :
Open in new window
The main function here is the public function process which inturn forwards the call to handleCommand