So the scenario is we are going to develop a web app. It will primarily consist of:
- Front End stuff (HTML/CSS/JS)
I am considering two approaches:
Package API separately into a *.war and deploy on the server. Write front end stuff and call those API. (This is what my previous company followed as we had API in hibernate ORM over RESTeasy deployed on JBOSS)
Package all the API and UI stuff into a *.jar. This is what my current company is following. Spring Framework, JSP.
As I understand it, using the first approach we can have more modularisation. We can point our UI to whatever API URL which can come in handy while testing, switching APIs and so on. Using second approach we can maintain higher level of integrity as in making the UI code more secure and uniform as we can reference them directly from API code. Although the catch is that the code becomes little unreadable and messy, thought that could be just a personal opinion.
What are other reasons behind taking these kind of approaches? Is my understanding correct? What approach is suitable in what scenarios?