Pages

Men

rh

10/09/2014

MVC 4 Interview Questions Part-1

1) What is MVC?
Ans. MVC stands for Model-View-Controller. It is a software design pattern which was introduced in 1970s. Also, MVC pattern forces a separation of concerns, it means domain model and controller logic are decoupled from user interface (view). As a result maintenance and testing of the application become simpler and easier.
 
2) Explain MVC design pattern?
Ans. MVC design pattern splits an application into three main aspects: Model, View and Controller.
Model - The Model represents a set of classes that describe the business logic i.e. business model as well as data access operations i.e. data model. It also defines business rules for data means how the data can be changed and manipulated.
View - The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the controller as the result. This also transforms the model(s) into UI.
Controller - The Controller is responsible to process incoming requests. It receives input from users via the View, then process the user's data with the help of Model and passing the results back to the View. Typically, it acts as the coordinator between the View and the Model.
 
2) Explain MVC design pattern?
Ans. MVC design pattern splits an application into three main aspects: Model, View and Controller.

Model - The Model represents a set of classes that describe the business logic i.e. business model as well as data access operations i.e. data model. It also defines business rules for data means how the data can be changed and manipulated.

View - The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the controller as the result. This also transforms the model(s) into UI.

Controller - The Controller is responsible to process incoming requests. It receives input from users via the View, then process the user's data with the help of Model and passing the results back to the View. Typically, it acts as the coordinator between the View and the Model.



3) What is Domain Driven Design and Development?
Ans. MVC design pattern splits an application into three main aspects: Model, View and Controller.
Domain-Driven Design (DDD) is a collection of principles and patterns that help developers to take design decisions to develop elegant systems for different domains. It is not a technology or methodology.

The main components of DDD are: Entity, Value Object, Aggregate, Service and Repository.

Entity- An object that has an identity- it is unique within the system, like Customer, Employee etc.

Value Object- An object that has no identity within the system like Rate, State etc.

Note: A value object can become an entity depending on the situation.

Aggregate: An aggregate root is a special kind of entity that consumers refer to directly. All consumers of the aggregate root are called as aggregate. The aggregate root guarantees the consistency of changes being made within the aggregate.

Service- A service is a way of dealing with actions, operations and activities within your application.

Repository- A repository is responsible to store and to retrieve your data. It is not a concern how and where data will be persist. So, it can be SQL server, oracle, xml, text file or anything else. Repository is not a Data Access Layer but it refers to a location for storage, often for safety or preservation.
 
4) What is MVP pattern?
This pattern is similar to MVC pattern in which controller has been replaced by the presenter. This design pattern splits an application into three main aspects: Model, View and Presenter.

Model - The Model represents a set of classes that describes the business logic and data. It also defines business rules for data means how the data can be changed and manipulated.

View - The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the presenter as the result. This also transforms the model(s) into UI.

Presenter - The Presenter is responsible for handling all UI events on behalf of the view. This receive input from users via the View, then process the user's data with the help of Model and passing the results back to the View. Unlike view and controller, view and presenter are completely decoupled from each other’s and communicate to each other’s by an interface.

Also, presenter does not manage the incoming request traffic as controller.
 
5) What is MVVM pattern?
MVVM stands for Model-View-View Model. This pattern supports two-way data binding between view and View model. This enables automatic propagation of changes, within the state of view model to the View. Typically, the view model uses the observer pattern to notify changes in the view model to model.

Model - The Model represents a set of classes that describes the business logic and data. It also defines business rules for data means how the data can be changed and manipulated.

View - The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the controller as the result. This also transforms the model(s) into UI.

View Model - The View Model is responsible for exposing methods, commands, and other properties that helps to maintain the state of the view, manipulate the model as the result of actions on the view, and trigger events in the view itself.

 
6)What is ASP.NET MVC?
ASP.NET MVC is an open source framework built on the top of Microsoft .NET Framework to develop web application that enables a clean separation of code. ASP.NET MVC framework is the most customizable and extensible platform shipped by Microsoft.
 
7)How MVC pattern works in ASP.NET MVC?
Working of MVC pattern in ASP.NET MVC is explained as below:

The Model in ASP.NET MVC can be broken down into several different layers as given below:

Objects or ViewModel or Presentation Layer
This layer contains simple objects or complex objects which are used to specify strongly-typed view. These objects are used to pass data from controller to strongly-typed view and vice versa. The classes for these objects can have specific validation rules which are defined by using data annotations. Typically, these classes have those properties which you want to display on corresponding view/page.

Business Layer

This layer helps you to implement your business logic and validations for your application. This layer make use of Data Access Layer for persisting data into database. Also, this layer is directly invoked by the Controller to do processing on input data and sent back to view.

Data Access Layer

This layer provides objects to access and manipulate the database of your application. Typically, this layer is made by using ORM tools like Entity Framework or NHibernate etc.






The View in ASP.NET MVC

The view is only responsible for displaying the data that is received from the controller as a result. It also responsible for transforming a model or models into UI which provide all the required business logic and validation to the view. By default, views are stored in the Views folder of an ASP.NET MVC application.


The Controller in ASP.NET MVC:-

The Controller in ASP.NET MVC, respond to HTTP requests and determine the action to take based upon the content of the incoming request. It receives input from users via the View, then process the user's data with the help of Model and passing the results back to the View.By default, controllers are stored in the Controllers folder an ASP.NET MVC application.
8)How Model, View and Controller communicate with each other in ASP.NET MVC?
There are following rules for communication among Model, View and Controller:

1. User interacts with the Controller.
2. There is one-to-many relationship between Controller and View means one controller can mapped to multiple views.
3. Controller and View can have a reference to model.
4. Controller and View can talk to each other.
5. Model and View cannot talk to each other directly. They communicate to each other with the help of controller.
 
9)What are advantages of ASP.NET MVC?
There are following advantages of ASP.NET MVC over Web Forms (ASP.NET):

1. Separation of concern - MVC design pattern divides the ASP.NET MVC application into three main aspects Model, View and Controller which make it easier to manage the application complexity
2. TDD - The MVC framework brings better support to test-driven development.
3. Extensible and pluggable - MVC framework components were designed to be pluggable and extensible and therefore can be replaced or customized easier then Web Forms.
4. Full control over application behaviour - MVC framework doesn’t use View State or server based forms like Web Forms. This gives the application developer more control over the behaviors of the application and also reduces the bandwidth of requests to the server.
5. ASP.NET features are supported - MVC framework is built on top of ASP.NET and therefore can use most of the features that ASP.NET include such as the providers architecture, authentication and authorization scenarios, membership and roles, caching, session and more.
6. URL routing mechanism - MVC framework supports a powerful URL routing mechanism that helps to build a more comprehensible and searchable URLs in your application. This mechanism helps to the application to be more addressable from the eyes of search engines and clients and can help in search engine optimization.
 
10)Explain brief history of ASP.NET MVC?
Here is the list of released version history of ASP.NET MVC Framework with theirs features.

ASP.NET MVC1 
1. Released on Mar 13, 2009
2. Runs on .NET 3.5 and with Visual Studio 2008 & Visual Studio 2008 SP1
3. MVC Pattern architecture with WebForm Engine
4. Html Helpers
5. Ajax helpers
6. Routing
7. Unit Testing

ASP.NET MVC2 :-

1. Released on Mar 10, 2010
2. Runs on .NET 3.5, 4.0 and with Visual Studio 2008 & 2010
3. Strongly typed HTML helpers means lambda expression based Html Helpers
4. Templated Helpers  UI helpers with automatic scaffolding & customizable templates
5. Support for DataAnnotations Attributes to apply model validation on both client and server sides.
6. Overriding the HTTP Method Verb including GET, PUT, POST, and DELETE
7. Areas for partitioning a large applications into modules
8. Asynchronous controllers


ASP.NET MVC3 :-

1. Released on Jan 13, 2011  Runs on .NET 4.0 and with Visual Studio 2010 The Razor view engine
2. Enhanced Data Annotations attributes for model validation on both client and server sides
3. Remote Validation
4. Compare Attribute
5. Session less Controller
6. Child Action Output Caching
7. Dependency Resolver
8. Entity Framework Code First support
9. Partial-page output caching
10. ViewBag dynamic property for passing data from controller to view
11. Global Action Filters
12. Better JavaScript support with unobtrusive JavaScript, jQuery Validation, and JSON binding
13. Use of NuGet to deliver software and manage dependencies throughout the platform

ASP.NET MVC4:-

1. Released on Aug 15, 2012
2. Runs on .NET 4.0, 4.5 and with Visual Studio 2010SP1 & Visual Studio 2012
3. ASP.NET WEB API
4. Enhancements to default project templates
5. Mobile project template using jQuery Mobile
6. Display Modes
7. Task support for Asynchronous Controllers
8. Bundling and minification
9. Support for the Windows Azure SDK

ASP.NET MVC5:-

1. Released on 17 October 2013
2. Runs on .NET 4.5, 4.5.1 and with Visual Studio 2012 & Visual Studio 2013
3. One ASP.NET
4. ASP.NET Identity
5. ASP.NET Scaffolding
6. Authentication filters - run prior to authorization filters in the ASP.NET MVC pipeline
7. Bootstrap in the MVC template
8. ASP.NET WEB API2
 

No comments :

Post a Comment