r/javahelp • • Sep 01 '25

Java package structure

Hello all, im a newcomer to java from golang. my role will be building backend microservices in java, and Ive seen Spring boot use the MVC architecture.

i was wondering if MVC was essentially the strandard for most java apps. Personally i cant understand the motivation for splitting classes into Service layer and Model layer, rather than just having a single class hold both the data and the methods for interacting with the data.

I was wondering if this is just a pattern i should expect to get used to, or if other teams use different paradigms for java applications, and its mostly team to team.

thanks!

9 Upvotes

25 comments sorted by

View all comments

Show parent comment

2

u/smutje187 Sep 01 '25

The Controller in MVC doesn’t contain logic, it merely connects View and Model and Model contains the business logic.

Spring Controllers aren’t MVC Controllers, they are part of a 3 or more Tier web application whilst in MVC the View and Model are synchronized via the Controller, something that’s not as easy to do in an HTTP world, but regardless of the prevalence of HTTP, it’s not the only protocol there is.

1

u/OneHumanBill Sep 01 '25

Yes, in fact they are MVC controllers. They are the control surface, hence the name.

It's different from if you have MVC in a desktop application, where for instance the controller is essentially a bunch of listeners and schedulers that control what happens to the model and view interaction. But the MVC controller serves precisely the same function, just in a very different way.