architecting an asp.net mvc solution

Post on 20-Jun-2015

238 Views

Category:

Software

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

Learn how to design a web solution that exploits the ASP.NET stack: in this talk we’ll find out how to set up an effective, idiomatic design that take advantage of both “out of the box” tools (e.g. MVC, Entity Framework) and bleeding edge, third party ones. Needing a SPA? We’ll understand how to take advantage of existing toolkits. Responsive design? Let’s talk Bootstrap looking at how it provides a useful and highly customizable taxonomy for UI elements. Having troubles implementing an efficient data access layer due to a lot of business rules? We’ll learn how to use LINQ as a mean to decompose those rules in simpler ones that can be composed in a flexible and efficient way. Are you concerned about performance and scalability issues? We’ll see how to implement CQRS in order to take advantage of ad hoc data models and introduce a service bus so to decouple front-end systems from back-end ones.

TRANSCRIPT

Architecting an ASP.NET MVC Solution

Andrea SaltarelloCEO @ managed/designs

andysal@gmail.comhttp://twitter.com/andysal74

http://slideshare.net/andysal

Who I am

1. CEO @ Managed Designs, striving to discover the perfect «sustainablesoftware development process»

• Customer has to be satisfied and pay

• Supplier has to have a reasonable markup

• Team members should be satisfied with their work

2. Founder and leader of UGIdotNET (first Italian .NET User Group): I need to share experiences in a peer to peer way

3. (Co)Author (together with Dino) of .NET: Architecting Applications for the Enterprise, by Microsoft Press

4. Basically, a software developer

Architecture: back to basics

The fundamental organization of a system embodied in its components, their relationships to each other, and to the environment, and the principles guiding its design and evolution.

[ISO/IEC 42010]

2014: Web vs. Architecture

Those «components» are (at least) the front end and the back end(s), whilst the «environment» is the Internet.

• Solution architecture

– Blueprint/pattern (e.g.: thin client, SPA)

– Visual Studio project(s)

• Front end architecture

• Back end architecture

• Cross cutting concerns (e.g.: security)

FRONT END

.Net DeveloperDays 2014

To SPA, or not to SPA?

«It depends»

Pro:• Responsiveness• Less bandwith usage

Cons:• Need for client side toolkit(s)• SEO

It does not have to (and it shouldn’t) be an «all or nothing» decision

.Net DeveloperDays 2014

DEMOAngularJS

What’s (in) a page, anyway?

As humans, it’s easy to understand the meaning of a page’s content, buthow can we have browsers and crawlers be aware of it, too? Taxonomyis the key.

• Bootstrap (http://getbootstrap.com) allows us to map html elementsonto a set of conceptual UI items

• Microdata (a.k.a. Microformats - http://www.schema.org) allowcrawlers to understand our document’s structure and index themaccordingly

– SEO

– Screen readers

.Net DeveloperDays 2014

DEMO

BootstrapLESS feat. BootstrapMicrodataGoogle Webmaster Tools feat Microdata

BACK END

.Net DeveloperDays 2014

By «MVC», you mean Model 2

In the Model 2 approach, end user requests are managed by a servlet that controls the flow, and uses components such as JavaBeans or EJBs to access and manipulate the data. It then uses JSPs to render the application content in a Web browser. [Java doc @ Oracle]

N.B.: Assert.AreSame(“servlet”, “controller”); //

.Net DeveloperDays 2014

Implementing Model 2 with ASP.NET MVC

In the Model 2 approach, end user requests are managed by a controllerthat controls the flow, and uses worker services to access and manipulate the data, which are returned as view models. It then uses views to render the application content in a Web browser. [Andrea Saltarello ]

Tips:

• Use the Force routing, Luke!

• Always implement a UrlBuilder

DEMOModel 2

Let’s talk «Application content» (reprise)

“application content” can both be a page or some kind of data such as: files, sitemaps, json, … That’s what ActionResults are there for

• ViewResult

• JsonResult

• ContentResult

• YourOwnPersonalResult (e.g.: MvcMate)

We could also use WebAPI… Until vNext comes

.Net DeveloperDays 2014

Sitemaps

Sitemaps are an easy way for webmasters to inform search engines about pages on their sites that are available for crawling. In its simplest form, a Sitemap is an XML file that lists URLs for a site along with additional metadata about each URL (when it was last updated, how often it usually changes, and how important it is, relative to other URLs in the site) so that search engines can more intelligently crawl the site.

[http://www.sitemaps.org/]

Important: both Bing and Google do support them

DEMO

Services

MvcMate

Sitemaps

Model 2: the icing on the cake stack

• Model 2 <3 IoC

• Model 2 <3 CQRS

• Model 2 <3 LET

.Net DeveloperDays 2014

DEMO

IoC

CQRS

LET

Crawler aware security

We know how to:

• have crawlers discovering our resources URLs…

• have crawlers better understand our application’s contents…

Is there a way to have crawlers doing those lovely tasks even on login protected content? Authorization filter you need, Luke!

DEMOCustom AuthorizationFilter

Demo code

[MVCM] MvcMate, https://mvcmate.codeplex.com (custom ActionResults).

– Binary package available for free on NuGet: http://www.nuget.org/packages/MvcMate/

[MERP] Merp, https://naa4e.codeplex.com/ (AngularJS, Bootstrap)

[UGI] UGIdotNET; have a look at the source code (Bootstrap and HTML+Microdata) of:

– Home page: http://www.ugidotnet.org

– Sitemap: http://www.ugidotnet.org/sitemap

– News page: http://www.ugidotnet.org/news/1369/Rilasciato-ReSharper-8-1

– Video page: http://www.ugidotnet.org/video/107800840/CPP03--Functional-Techniques-in-C++

top related