Reputation:
How can I know if a Java app uses the MVC design pattern? For example I want to know if this app from github uses the MVC design pattern: https://github.com/eveningstar33/GoalTracker
It is a fullstack app, the frontend is made in Angular and the backend is made in Spring Boot. And if yes I want to know who is the Model? I think that RestController is the Controller and the Angular app is the View. Isn't it? Or if an app uses Spring MVC does it also use MVC design pattern?
Upvotes: 3
Views: 685
Reputation: 7998
MVC part in Spring MVC stays for implementation (very good implementation :)) of broader JSP/Sevlets based MVC concept, where typically we have Front Controller Servlet, which dispatches requests to corresponding View Controllers and resolve/prepare result views to be rendered for user.
The MVC parts could change when we have both Angular (or any other Single Page Application JS framework) and Spring MVC working together. As in Angular usually you have "Controller" class per each component, which can have a lot of logic inside, connecting to different services. So less logic stays on server and it acts as a proxy to DAO layer to perform CRUD operations. For such cases it is quite common to see:
Upvotes: 1
Reputation: 2808
MVC is one of the design patterns in software development. Model is usually a POJO (Plain Java Object) that encapsulates the data of the business objects, View is the one that users interact with that is also responsible to take request from users and render response and Controller sits in between View and Model to transfer data as well as act as a navigation decision maker.
You can write the back end in Spring Boot providing HTTP APIs to any client including Angular. Angular internally uses TypeScript ( a super set of JavaScript ) that you can use to just consume the APIs.
Here is one such example, where I have written written services in Sprint Boot - https://github.com/royalghost/PortfolioTrackerServices
And then there is a separate project that consumes the above services using Angular - https://github.com/royalghost/PortfolioServicesTrackerClient
Spring MVC is one of the framework that implements the MVC design patterns. You can take a look at a separate project that uses Spring MVC - https://github.com/royalghost/UserRegistration . Also note that this project uses Spring Boot since Spring Boot is just an easy way to put all the required libraries together to quickly build, start and deploy an application.
Angular is more popular with Single Page Application ( SPA ) and a lot of server side computation is now pushed towards client ( this is also to scale the product. ) Therefore, it is completely up to the developer on which design patterns or architecture to choose when using the same technology and stacks.
References: MVC - https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller Angular - https://angular.io/guide/architecture
Upvotes: 0