I am facing a complicated design issue. I would like to have your opinions on what approach should I take.
I am dealing with the code written by previous programmers. It is a small booking web application.
The web application has a single servlet with a big if-else block (with around 80 conditions) where it compares one of the parameter and decides where to redirect the request and what processing to do. The same servlet has around 55 functions which are being called by different parts of the if-else block. These functions connect directly to the data access objects. There are a few javabeans which are used by the functions and the data access objects. The data access objects contain business logic and the data access code. Everything tangled together.
My boss wants me to add more functions to this web app. I tried adding stuff to it but it breaks other things. So I started cleaning up and cleaned up the data access objects and removed business logic from them. In short added an extra layer before the data access objects. But I havent integrated it with the main application yet. And now I am trying to remove all the code from the servlet and form a business layer with those functions in different classes.
But the servlet still has that bigg if-else block. Should I make one servlet for each condition or group them based on commonality. I was wondering how much code should every servlet have? I need to get request parameters put them into session variables, call appropriate business methods and redirect to appropriate page. Even that is a lot of code. I was wondering how much code should an ideal servlet have and how to ideally decide on the number of servlets required ?
And this system is running right now. So I cannot even do an overhaul and implement the web app with a framework. It has to be gradual and I need to add functions to the web app too. It is a nightmare. Please give me some suggestions on how to approach this situation. I am a newbie and totally new to such situations.