BUILDING WEB APPS WITH ASP.NET MVC AND NOSQL

Preview:

DESCRIPTION

This talk guides you through building modern web applications using ASP.NET MVC and MongoDB, one of the most popular NoSQL databases. You will learn some best practices for getting started with MVC. We’ll cover building rich-forms to accept user input. And if time permits, we might even add some client-side techniques using jQuery and MVC. All of this will be built upon the powerful non-relational database MongoDB. We will discuss the origins of the so-called NoSQL movement and why you might choose a non-relational database over SQL Server. You’ll also see our data access layer will be built using LINQ to MongoDB. Of course, you won’t be in for a night of PowerPoint. This talk is a series of interactive demos using Visual Studio 11, Windows 8, and C#.

Citation preview

NoSQL, MVC, and Rich Formsby Michael Kennedy | @mkennedy | michaelckennedy.net

DEVELOPMENTOR

Introduction

* Introduction to NoSQL* Why NoSQL* CRUD with NoSQL databases* HTML Helpers* Model Binding* Unobtrusive Validation* Unified Client and Server Validation* View Models* JavaScript-Friendly Environment* Single-Page Applications (MVC 4)

DEVELOPMENTOR

What's Your Experience with NoSQL?

DEVELOPMENTOR

What is NoSQL?

The NoSQL movement is about re-evaluating the constraints and scalability of data storage systems in the light of the way modern web applications generate and consume data.

DEVELOPMENTOR

What is NoSQL?

The NoSQL movement is about re-evaluating the constraints and scalability of data storage systems in the light of the way modern web applications generate and consume data.

DEVELOPMENTOR

Why NoSQL?

Axiom: A proposition whose truth is so evident that no reasoning or demonstration can make it plainer.

DEVELOPMENTOR

Starting from an RDBMS is virtually an axiom of software development.

When was the last time you consciously evaluated alternatives to an RDBMS?

Why NoSQL?

DEVELOPMENTOR

You can keep your ‘object / relational impedance mismatch’, thank you very much!

MongoDB: A Powerful NoSQL Database

Combining the best features of document databases, key-values stores, and RDBMS.

DEVELOPMENTOR

http://www.mongodb.org/

MongoDB:Just an Example

DEVELOPMENTOR

Is NoSQL only for Start-ups?

DEVELOPMENTOR

DEVELOPMENTOR

Is NoSQL only for Start-ups?

Getting Started

DEVELOPMENTOR

The Project: Amazoon

DEVELOPMENTOR

The Data Model: Amazoon

DEVELOPMENTOR

Programming NoSQL

DEVELOPMENTOR

Find several provider libraries on NuGet, including the Official 10Gen C# driver.

Demo - Part 1: Amazoon Needs a Data Layer

Time to upgrade Amazoon: Amazoon needs to be able to do basic queries and inserts / updates.

DEVELOPMENTOR

Demo - Part 1: Amazoon Needs a Data Layer

DEVELOPMENTOR

The GET, POST, Redirect Pattern

DEVELOPMENTOR

GET/book/edit/42

POST/book/edit/42 + changes

HTTP 302 -

Red

irect

/book

/show

/42

update data

Edit data locally

The GET, POST, Redirect Pattern

DEVELOPMENTOR

1

2

3

4

Demo - Part 2: Forms, Model Binding, and HTML Helpers

"Pure" HTML forms are valid but not optimal in MVC. Make use of @Html extensions. Html.BeginForm(), Html.TextBoxFor(), etc. Usually, this is far easier with Model Binding.

DEVELOPMENTOR

Demo - Part 2: Forms, Model Binding, and HTML Helpers

Time to upgrade Amazoon: Amazoon needs an admin section where we can create categories and books.

DEVELOPMENTOR

Demo - Part 2: Forms, Model Binding, and HTML Helpers

DEVELOPMENTOR

Demo - Part 2: Forms, Model Binding, and HTML Helpers

Well, that mostly worked. But it was clunky on several levels. * ViewBag is untyped and non-discoverable* Many parameters "capture" the form values* What about validation?

DEVELOPMENTOR

Demo - Part 3: View Models and Validation

Now that we got the site working with the new features, let's clean it up. * View Models (Model Binding at the next level)* Validation (is easier with View Models)

DEVELOPMENTOR

Demo - Part 3: View Models and Validation

DEVELOPMENTOR

Demo - Part 3: View Models and Validation

DEVELOPMENTOR

Demo - Part 4: Adding Real Usability with Client-Side Code

Time to upgrade Amazoon (again): Comments and discussions around books. These are already in place, but the full-page refresh is not usable on these potentially large pages.

DEVELOPMENTOR

Demo - Part 4: Adding Real Usability with Client-Side Code

DEVELOPMENTOR

Demo - Part 4: Adding Real Usability with Client-Side Code

DEVELOPMENTOR

Fully Client-Side MVC Applications

MVC 4 introduces the concept of Single-Page Applications (think gmail). These combine many technologies: * MVC and ASP.NET Web API* Knockout.js* Upshot.js* HTML5

DEVELOPMENTOR

Fully Client-Side MVC Applications

DEVELOPMENTORhttp://bit.ly/sanderson-spa

I Want My Management Tools

DEVELOPMENTOR

Scaling-Out is Easier With NoSQL

So you say it's fast, eh? What do you mean by fast?

DEVELOPMENTOR

Dropping ACID with MongoDB on USTREAM

Conclusion (MVC)

Just some of the features we've explored in MVC:

* HTML Helpers* Model Binding* Unobtrusive Validation* Unified Client and Server Validation* View Models* JavaScript-Friendly Environment* Single-Page Applications (MVC 4)

DEVELOPMENTOR

Conclusion (NoSQL)

DEVELOPMENTOR

Just some of the features we've explored in NoSQL:

* Your database is a choice you make for each project* NoSQL => Non-relational* Strongly supports horizontal scale-out* LINQ works great

More from DevelopMentor

DEVELOPMENTOR

* Guerrilla .NET (May 7th in Boston) * Essential ASP.NET MVC * JavaScript and jQuery * HTML5 * + lots more @mkennedy@DevelopMentor_

http://www.develop.com/training-courses/web