Design the application architecture - Objective 1.1: Plan the application layers Flashcards
What folder usually contains the model or data classes for an application?
The Models folder
What is one advantage of placing model classes in a separate assembly?
To allow the model classes to be used by more than one application.
What is a domain model?
It represents the data you work with in the middle tier of an application.
What is a view model?
It represents the data you work with in the presentation layer. Any data present in the view comes from the view model.
What is an input model?
It represents the data submitted from the client to the server with each individual HTTP request.
What are model binders?
A simple way to map posted form data to a type and pass that type to an action method as a parameter.
What is the DefaultModelBinder?
The default model binder in ASP.Net MVC that automatically maps input values to model properties if the names match exactly.
How do you create a custom model binder?
Implement the IModelBinder interface.
What is one reason to use custom model binders?
To support abstract classes and interfaces. The default model binder does not support them.
What do controllers do?
Handle incoming requests, handle user input and interaction, and execute application logic.
What class do controllers inherit from?
ControllerBase
What are action methods?
Methods on a controller that map to the user’s interactions with the server.
What is an action result?
The outcome from calling an action method.
Where is the routing table stored?
In the global.asax file.
What does routing do in ASP.Net MVC?
Maps urls to controllers and action methods.
What is the default routing format?
{controller}/{action}/{id}
What does the routing engine do?
Analyze urls and pass control to a route handler.
What is a route handler?
The route handler finds an HTTP handler or class implementing the IHttpHandler interface to handle the request.
What is the default handler in ASP.Net MVC?
MvcHandler
What does the MvcHandler class do?
Extracts the controller name from the request and sends it to a controller factory to return the appropriate controller.
How do you create a custom controller factory?
Create a class that implements the IControllerFactory interface.
What does the ActionName attribute do?
Gives an action method a different name.
Ex:
[ActionName(“MyName2”)]
public ActionResult MyName()
What does the AcceptVerbs attribute do?
Specifies which HTTP verbs an action method will respond to.
Ex:
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult MyAction()
What does the NonAction attribute do?
Indicates that a controller method is not an action.
What does the OutputCache attribute do?
Marks an action method whose output will be cached.
Ex:
[OutputCache(Duration=60)]
public ActionResult MyAction()
What does the ValidateInput attribute do?
Indicates whether an action method’s parameters must be validated.
Ex:
[ValidateInput(false)]
public ActionResult MyAction()
What does the HandleError attribute do?
Used for handling exceptions thrown by the action method to which it is applied.
Ex:
[HandleError(View=”DivideByZero”)]
public ActionResult MyAction()
How do you create a custom action filter?
Create a class that inherits from the ActionFilter class.
When should you use asynchronous processing in your action methods?
When the action method is long-running, network-bound, or IO-bound, or when you want to allow the user to cancel running the method.
How do you make an action method asynchronous?
Mark it as async and change its return type to Type<ActionResult>.</ActionResult>
Ex: public async Task<ActionResult> List() { ... }
What 3 ways can you use asynchronous processing in ASP.Net MVC?
- Mark an action method as async and change its return type to Task<ActionResult></ActionResult>
- Use Tasks inside a synchronous action method.
- Load asynchronously from the client using JavaScript to call back to the server.
What is an MVC view?
The part of the application responsible for display information to the user and receiving the user’s input.
What is a strongly-typed view?
A view whose @model directive is set to a specific class.
What is a view-specific model?
A class that is used in the @model directive of a view and is not usually directly related to a domain model.
What is a partial view?
The ASP.Net MVC version of a user control. Does not include <html> and <head> tags.
What is a layout page?
The ASP.Net MVC version of a master page. Allows sharing of design across multiple views.
What is a scaffold template?
A template that creates standard pages as part of the process when creating a project.
What is the basic syntax to output text from a model property inside a razor view?
@model.PropertyName
What is the basic syntax of a code block inside a razor view?
@{ // Add code here }
What is the basic syntax of an if statement inside a razor view?
@if (article.HasContent) { // Add code or HTML here }
What is the basic syntax of calling a generic method inside a razor view?
@(MyClass.MyMethod<MyType>())</MyType>
What class does the razor view engine inherit from?
BuildManagerViewEngine
What is the HTML helper?
A class with static methods used in views in order to help generate HTML.
Where should validation logic go: client-side or server-side?
Both
What is scalability?
The capability of a system to handle a growing amount of work.
What are the two primary ways to scale an application?
Horizontally and vertically
What is horizontal scaling?
Scaling that involves adding or removing additional nodes from a system as demand fluctuates. A load balancer determines which server in the web farm should be called.
What are some of the architectural considerations that must be addressed in horizontal scaling?
Sessions, caching, and location for storing shared files (if you application provides file management functionality like SharePoint does)
What is vertical scaling?
Adding resources to a single system including additional CPU’s, memory, or hard drive space.
What are some of the architectural considerations that must be addressed in vertical scaling?
Threading, input/output (I/O), garbage collection, and availability since any part of the system can be a single point of failure.
Which primary way of scaling is ultimately limited and cannot scale beyond a certain point?
Vertical
What advantages does cloud-based hosting such as Windows Azure provide in terms a scalability?
Scalability is immediate and can automatically scale as usage grows. It can also provide highly scalable data storage for relational and NoSQL databases.
What are the three ways to manage the creation of a database when using Entity Framework?
Database First, Code First, and Model First
What is the Database First approach in Entity Framework?
Leveraging an existing database schema to create entities.
What is the Code First approach in Entity Framework?
Creating the object model first and use it to create the database schema.
What is the Model First approach in Entity Framework?
Creating the object model visually using a tool and use it to create the database schema.
Which design pattern is one of the most used to abstract data access in Entity Framework?
Repository