0% found this document useful (0 votes)
32 views7 pages

Chap5 MVC

Uploaded by

hi827019
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views7 pages

Chap5 MVC

Uploaded by

hi827019
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

What is MVC?

The Model-View-Controller (MVC) framework is an architectural/design pattern that separates an


application into three main logical components Model, View, and Controller.

The main goal of this design pattern was to solve the problem of users controlling a large and
complex data set by splitting a large application into specific sections that all have their own
purpose.

MVC is used to create

 Desktop graphical user interfaces (GUIs)


 Industry-standard web development frameworks
 To create scalable and extensible projects.
 It is also used for designing mobile apps.

Components of MVC

The MVC framework includes the following 3 components:

 Controller

 Model

 View
MVC Architecture Design

Controller:

The controller is the component that enables the interconnection between the views and the
model so it acts as an intermediary.

It processes all the business logic and incoming requests, manipulates data using
the Model component, and interact with the View to render the final output.

Responsibilities:

 Receiving user input and interpreting it.

 Updating the Model based on user actions.

 Selecting and displaying the appropriate View.

View:

The View component is used for all the UI logic of the application.

It generates a user interface for the user.

Views are created by the data which is collected by the model component but these data aren’t
taken directly but through the controller.

It only interacts with the controller.

Responsibilities:

 Rendering (Represent )data to the user in a specific format.

 Displaying the user interface elements.

 Updating the display when the Model changes.

Model:
The Model component corresponds to all the data-related logic that the user works with.

It can add or retrieve data from the database.

This can represent either the data that is being transferred between the View and Controller
components or any other business logic-related data.

It responds to the controller’s request because the controller can’t interact with the database by
itself.

The model interacts with the database and gives the required data back to the controller.

Responsibilities:

 Managing data: CRUD (Create, Read, Update, Delete) operations.

 Enforcing business rules.

 Notifying the View and Controller of state changes.

Q.2) Advantages of MVC


 Codes are easy to maintain and they can be extended easily.

 The MVC model component can be tested separately.

 The components of MVC can be developed simultaneously.

 It reduces complexity by dividing an application into three units. Model, view, and
controller.

 It supports Test Driven Development (TDD).

 It works well for Web apps that are supported by large teams of web designers and
developers.

 This architecture helps to test components independently as all classes and objects are
independent of each other

 Search Engine Optimization (SEO) Friendly.

Q.3) Disadvantages of MVC


 It is difficult to read, change, test, and reuse this model

 It is not suitable for building small applications.

 The inefficiency of data access in view.

 Increased complexity and Inefficiency of data

 The framework navigation can be complex as it introduces new layers of abstraction which
requires users to adapt to the decomposition criteria of MVC.

Example Of MVC Frameworks

Ruby on Rails Django ,CherryPy, Spring MVC Catalyst Rails Laravel, Symphony
Q.4)Spring Frame work Architecture:

Modules of the Spring framework

 Core Container: Includes fundamental components like IoC and DI, helping to
manage object creation and configuration.
 Data Access/Integration: Provides tools for interacting with databases, handling
transactions, and integrating with other data sources.
 Web: Supports building web applications, including MVC (Model-View-
Controller) architecture.
 AOP (Aspect-Oriented Programming) and Instrumentation: Allows adding
cross-cutting concerns like logging or security in a modular way.
 Test: Offers support for testing Spring components, ensuring that they work as
expected.
Q,5)Explain Aspect Oriented Programming(AOP)

 One of the key components of Spring is the AOP framework.


 Aspect: A module which has a set of APIs providing cross-cutting requirement.
 The key unit of modularity in OOP is the class, whereas in AOP the unit of
modularity is the
aspect.
 Aspects are implement using regular classes.
 AOP breaks the program logic into distinct parts (called concerns). It is used to
increase modularity by cross-cutting concerns.
 A cross-cutting concern is a concern that can affect the whole application and
should be centralized in one location in code as possible, such as transaction
management, authentication, logging, security etc.
 Join point:A joint point is any point in your program such as method execution,
exception handling,field access etc.Spring support only method execution join
point
 Pointcut:It is an expression language of AOP that matches join points.

Q,6)Explain Dependency Injection (DI):


 It is a design pattern used to implement IoC.
 It is a programming technique that makes a class independent of its dependencies.
 It make java application loosely coulpled.
 It allows the creation of dependent objects outside of a class and inject them at
runtime.
 With dependencies injected from the outside, each code component becomes more
modular and easier to maintain, and do not affect others.

Q.9)Advantages of Spring MVC Framework

Spring Spring Boot


It is used to develop enterprise It is used to develop REST APIs.
applications.
The most important feature of the Spring The most important feature of the Spring
Framework is dependency injection. Boot is Autoconfiguration.
It helps to create a loosely coupled It helps to create a stand-alone
application. application.
To run the Spring application, we need to Spring Boot provides embedded servers
set the server explicitly. such as Tomcat and Jetty etc.
To run the Spring application, a deployment There is no requirement for a deployment
descriptor is required. descriptor.
In this developers write lots of code. It reduces the lines of code.
It doesn’t provide support for the in- It provides support for the in-memory
memory database. database such as H2.
Developers need to write boilerplate code In Spring Boot, there is reduction in
for smaller tasks. boilerplate code.
Developers have to define dependencies pom.xml file internally handles the
manually in the pom.xml file. required dependencies.
Q.10) Difference between Spring and Spring Boot

Q.11)What is Spring Boot


Spring Boot is a project that is built on the top of the Spring Framework. It provides an
easier and faster way to set up, configure, and run both simple and web-based
applications.

Spring Boot Features


 Auto Configuration: Absolutely no requirement for XML configuration
 Creates stand-alone spring application with minimal configuration needed.
 Embedded Servers: It has embedded tomcat, jetty which makes it just code and run the
application
 Extensive Plugin Support
 Actuator:It helps you to monitor and manage your application when you push it to
production. These actuators include auditing, health, CPU usage, HTTP hits, and metric
gathering, and many more that are automatically applied to your application.

 Customizable:You can change the settings any time whenever it’s neede.

You might also like