SlideShare a Scribd company logo
ASP.NET MVC: non solo «tennologgia»Andrea Saltarello(Solution) Architect @ ManagedDesigns S.r.l. – http://www.manageddesigns.itandysal@gmail.comhttp://blogs.ugidotnet.org/papehttp://twitter.com/andysal74http://creativecommons.org/licenses/by-nc-nd/2.5/
Innanzitutto…Grazie,                                     ! 
Agenda#ifdef NIUBBO MVC 1-2-3Controller->ViewView->ControllerAspNetMvc.More();
ModelView ControllerFormulato nel 1979 da TrygveReenskaug, membro del team Smalltalk @ Xerox PARCLa prima motivazione di design è:Separare gli aspetti di presentazione da quelli di dominio.E' la “radice concettuale” di tutti gli attuali pattern:Model ViewPresenter, Presenter-First, Passive View, Presentation Abstraction Control, Presentation ModelModelViewViewModel...
Model view controllerModelStateQueryStateChangeChange NotificationViewControllerView SelectionUser GesturesMethod InvocationsEvents
MVC: falsi mitiLo scopo del Controller non è di separare la ViewdalModel. La responsabilità del Controller è di fare damediatoretral'utente e l'applicazione, non tra la View e ilModel.Spessosiparla di MVC, ma siintendeModel 2
Model 2In a Model 2 application, requests from the client browser are passed to the controller, which is a servlet. The controller decides which view (JSP) it will pass the request to. The view then invokes methods in a JavaBean (which may access a database) and returns the Response object to the Web container, which is then passed on to the client browser. [Wikipedia]Legenda:Servlet->HttpHandler->Front Controller [P of EAA, 344]
JSP->Controller->Page Controller [P of EAA, 333]Introduzione a ASP.NET MVC (1/4)http://host/webapp/Customer/Detail/1
Introduzione a ASP.NET MVC (2/4)http://host/webapp/Customer/Detail/1
Introduzione a ASP.NET MVC (3/4)http://host/webapp/Customer/Detail/1
Introduzione a ASP.NET MVC (4/4)http://host/webapp/Customer/Detail/1
Navigation FlowLe action restituiscono un valore di tipo ActionResult. “Pragmapolimorficamente” parlando:ViewResult. Restituito dal metodoView.PartialViewResult. Restituito dal metodoPartialView.RedirectToRouteResult. RestituitodaimetodiRedirectToAction e RedirectToRoute.
RedirectResult. RestituitodalmetodoRedirect.
ContentResult. RestituitodalmetodoContent.
JsonResult. RestituitodalmetodoJson.
EmptyResult. Restituitodalle action chevoglianorestituire “null”.
YourOwnPersonalResult(semi-cit), restituito da una factory ad hocASP.Net MVC
Dati: Controller->ViewPer trasferire dati dal controller alla view:ViewDataYourView.Model=Presentation View Model
ASP.Net MVC
Dati: View->ControllerPer trasferire dati dalla view al controller:Parametridella action (convention over configuration): ognielemento in query string èmappatosu un parametroomonimoognielemento del <form /> èmappatosu un parametroomonimoFormCollection>>>Model binding<<<
ASP.Net MVC
Data EntryBuilt in:Usare i metodi helper per definire i “campi”Taggareil ViewModel mediante DataAnnotationsRicordarsi Html.ValidationMessageFor<>() e/o Html.ValidationSummary()[Opzionale]Impostare .input-validation-error nel css[Opzionale]: EditorTemplates, DisplayTemplates
ASP.Net MVC
Data Entry <3 JQueryClient side validationInclusione degli script JS<% Html.EnableClientSideValidation(); %>JQuery plug-in, es:JQuery UI (tab, datepicker, …)JQGridAssert.IsTrueLove(EditorTemplates, JQuery)
ASP.Net MVC
AspNetMvc.More();Esempi:[FX4 only]<%: … %> (equivalente a <% =Html.Encode(…) %>)IoCCustom ActionResult:Generare ThumbnailGenerare Atom/RSS (http://www.ugidotnet.org/Article/Detail/280)“Componentization”: RenderPartial+RenderActionTestAree
ASP.Net MVC
MVC @ ManagedDesignsIn azienda usiamo il toolkit MVC dalle prime CTP della v1, ed abbiamo raggiunto una struttura «standardizzata» dei progetti:Model 3LayeredExpressionTrees
MVC goes Model 3Model 2 separa il Controller in:Front ControllerPage ControllerModel 3 separa il Model in:View Model: rappresenta i dati che la view si impegna a presentare all’utenteWorker Service: è la façade che il page controller utilizza per produrre il View ModelE’ il Single ResponsibilityPrinciple, baby!

More Related Content

PDF
Tutte le novità di ASP.NET MVC3
Manuel Scapolan
 
PDF
ASP.NET MVC: Full Throttle
Andrea Saltarello
 
PPTX
ASP.NET MVC 2.0
XeDotNet
 
PPTX
ASP.NET MVC 3: se non ora, quando?
Giorgio Di Nardo
 
PPTX
NHDay Introduction to LINQ2NH
Gian Maria Ricci
 
PPSX
Asp.Net MVC 3 - Il Model View Controller secondo Microsoft
Stefano Benedetti
 
PPTX
Design pattern architetturali Model View Controller, MVP e MVVM
Riccardo Cardin
 
PPTX
ASP.NET MVC
Raffaele Fanizzi
 
Tutte le novità di ASP.NET MVC3
Manuel Scapolan
 
ASP.NET MVC: Full Throttle
Andrea Saltarello
 
ASP.NET MVC 2.0
XeDotNet
 
ASP.NET MVC 3: se non ora, quando?
Giorgio Di Nardo
 
NHDay Introduction to LINQ2NH
Gian Maria Ricci
 
Asp.Net MVC 3 - Il Model View Controller secondo Microsoft
Stefano Benedetti
 
Design pattern architetturali Model View Controller, MVP e MVVM
Riccardo Cardin
 
ASP.NET MVC
Raffaele Fanizzi
 

Similar to MVC2: non solo tecnologia (20)

PPTX
Asp.NET MVC Framework
DotNetMarche
 
PPTX
Migliora il tuo codice con knockout.js
Andrea Dottor
 
PPTX
Asp.Net MVC 2 :: VS 2010 Community Tour
Andrea Balducci
 
PDF
Hands on MVC - Mastering the Web
Claudio Gandelli
 
PPTX
Asp.net 4 Community Tour VS2010
Fabrizio Bernabei
 
PPTX
Alessandro Forte - MVP vs MVC
Alessandro Forte
 
PDF
MVC and Struts 1
Tarin Gamberini
 
PPTX
Novità di Asp.Net 4.0
Gian Maria Ricci
 
PDF
Dal RenderFragment ai Generics, tips for Blazor developers
Andrea Dottor
 
PPTX
Fe02 ria con breeze e knockout
DotNetCampus
 
PDF
AngularJS-Intro
Vittorio Conte
 
PDF
Introduzione a Struts
Andrea Colleoni
 
PPTX
ASP.NET MVC 6 - uno sguardo al futuro
Andrea Dottor
 
PPT
Zend Framework Workshop Parte2
massimiliano.wosz
 
PPT
Zendframework Parte2
massimiliano.wosz
 
PDF
Fare con Zend Framework 2 ciò che facevo con ZF1
Steve Maraspin
 
PPTX
Applicazioni web con Asp.Net MVC 6
Michele Aponte
 
PPTX
Integrazione continua con TFS Build
Gian Maria Ricci
 
PDF
Niccolò Becchi: Introduzione a GWT
firenze-gtug
 
PDF
Introduzione ai componenti in Angular 4
Giovanni Buffa
 
Asp.NET MVC Framework
DotNetMarche
 
Migliora il tuo codice con knockout.js
Andrea Dottor
 
Asp.Net MVC 2 :: VS 2010 Community Tour
Andrea Balducci
 
Hands on MVC - Mastering the Web
Claudio Gandelli
 
Asp.net 4 Community Tour VS2010
Fabrizio Bernabei
 
Alessandro Forte - MVP vs MVC
Alessandro Forte
 
MVC and Struts 1
Tarin Gamberini
 
Novità di Asp.Net 4.0
Gian Maria Ricci
 
Dal RenderFragment ai Generics, tips for Blazor developers
Andrea Dottor
 
Fe02 ria con breeze e knockout
DotNetCampus
 
AngularJS-Intro
Vittorio Conte
 
Introduzione a Struts
Andrea Colleoni
 
ASP.NET MVC 6 - uno sguardo al futuro
Andrea Dottor
 
Zend Framework Workshop Parte2
massimiliano.wosz
 
Zendframework Parte2
massimiliano.wosz
 
Fare con Zend Framework 2 ciò che facevo con ZF1
Steve Maraspin
 
Applicazioni web con Asp.Net MVC 6
Michele Aponte
 
Integrazione continua con TFS Build
Gian Maria Ricci
 
Niccolò Becchi: Introduzione a GWT
firenze-gtug
 
Introduzione ai componenti in Angular 4
Giovanni Buffa
 
Ad

More from Andrea Saltarello (14)

PPTX
Da Rotor a .NET Core ed indietro: Microsoft &lt;3 Open Source
Andrea Saltarello
 
PDF
The Fine Art of Time Travelling: implementing Event Sourcing
Andrea Saltarello
 
PDF
ASP.NET Core essentials
Andrea Saltarello
 
PDF
Implementing Event Sourcing in .NET
Andrea Saltarello
 
PDF
Idiomatic Domain Driven Design: implementing CQRS
Andrea Saltarello
 
PDF
Architecting an ASP.NET MVC Solution
Andrea Saltarello
 
PDF
Never Mind the Bollocks: here's the Domain Driven Design
Andrea Saltarello
 
PDF
Layered Expression Trees feat. CQRS
Andrea Saltarello
 
PDF
How I did it (in .NET): idiomatic Domain Driven Design
Andrea Saltarello
 
PDF
Code Contracts and Generics: implementing a LINQ-enabled Repository
Andrea Saltarello
 
PDF
Idiomatic Domain Driven Design
Andrea Saltarello
 
PPTX
Build a LINQ-enabled Repository
Andrea Saltarello
 
PDF
Layered Expression Trees: una terza via (idiomatica) verso il DDD
Andrea Saltarello
 
PDF
From relational data to object spaces
Andrea Saltarello
 
Da Rotor a .NET Core ed indietro: Microsoft &lt;3 Open Source
Andrea Saltarello
 
The Fine Art of Time Travelling: implementing Event Sourcing
Andrea Saltarello
 
ASP.NET Core essentials
Andrea Saltarello
 
Implementing Event Sourcing in .NET
Andrea Saltarello
 
Idiomatic Domain Driven Design: implementing CQRS
Andrea Saltarello
 
Architecting an ASP.NET MVC Solution
Andrea Saltarello
 
Never Mind the Bollocks: here's the Domain Driven Design
Andrea Saltarello
 
Layered Expression Trees feat. CQRS
Andrea Saltarello
 
How I did it (in .NET): idiomatic Domain Driven Design
Andrea Saltarello
 
Code Contracts and Generics: implementing a LINQ-enabled Repository
Andrea Saltarello
 
Idiomatic Domain Driven Design
Andrea Saltarello
 
Build a LINQ-enabled Repository
Andrea Saltarello
 
Layered Expression Trees: una terza via (idiomatica) verso il DDD
Andrea Saltarello
 
From relational data to object spaces
Andrea Saltarello
 
Ad

MVC2: non solo tecnologia

  • 1. ASP.NET MVC: non solo «tennologgia»Andrea Saltarello(Solution) Architect @ ManagedDesigns S.r.l. – http://[email protected]://blogs.ugidotnet.org/papehttp://twitter.com/andysal74http://creativecommons.org/licenses/by-nc-nd/2.5/
  • 3. Agenda#ifdef NIUBBO MVC 1-2-3Controller->ViewView->ControllerAspNetMvc.More();
  • 4. ModelView ControllerFormulato nel 1979 da TrygveReenskaug, membro del team Smalltalk @ Xerox PARCLa prima motivazione di design è:Separare gli aspetti di presentazione da quelli di dominio.E' la “radice concettuale” di tutti gli attuali pattern:Model ViewPresenter, Presenter-First, Passive View, Presentation Abstraction Control, Presentation ModelModelViewViewModel...
  • 5. Model view controllerModelStateQueryStateChangeChange NotificationViewControllerView SelectionUser GesturesMethod InvocationsEvents
  • 6. MVC: falsi mitiLo scopo del Controller non è di separare la ViewdalModel. La responsabilità del Controller è di fare damediatoretral'utente e l'applicazione, non tra la View e ilModel.Spessosiparla di MVC, ma siintendeModel 2
  • 7. Model 2In a Model 2 application, requests from the client browser are passed to the controller, which is a servlet. The controller decides which view (JSP) it will pass the request to. The view then invokes methods in a JavaBean (which may access a database) and returns the Response object to the Web container, which is then passed on to the client browser. [Wikipedia]Legenda:Servlet->HttpHandler->Front Controller [P of EAA, 344]
  • 8. JSP->Controller->Page Controller [P of EAA, 333]Introduzione a ASP.NET MVC (1/4)http://host/webapp/Customer/Detail/1
  • 9. Introduzione a ASP.NET MVC (2/4)http://host/webapp/Customer/Detail/1
  • 10. Introduzione a ASP.NET MVC (3/4)http://host/webapp/Customer/Detail/1
  • 11. Introduzione a ASP.NET MVC (4/4)http://host/webapp/Customer/Detail/1
  • 12. Navigation FlowLe action restituiscono un valore di tipo ActionResult. “Pragmapolimorficamente” parlando:ViewResult. Restituito dal metodoView.PartialViewResult. Restituito dal metodoPartialView.RedirectToRouteResult. RestituitodaimetodiRedirectToAction e RedirectToRoute.
  • 16. EmptyResult. Restituitodalle action chevoglianorestituire “null”.
  • 18. Dati: Controller->ViewPer trasferire dati dal controller alla view:ViewDataYourView.Model=Presentation View Model
  • 20. Dati: View->ControllerPer trasferire dati dalla view al controller:Parametridella action (convention over configuration): ognielemento in query string èmappatosu un parametroomonimoognielemento del <form /> èmappatosu un parametroomonimoFormCollection>>>Model binding<<<
  • 22. Data EntryBuilt in:Usare i metodi helper per definire i “campi”Taggareil ViewModel mediante DataAnnotationsRicordarsi Html.ValidationMessageFor<>() e/o Html.ValidationSummary()[Opzionale]Impostare .input-validation-error nel css[Opzionale]: EditorTemplates, DisplayTemplates
  • 24. Data Entry <3 JQueryClient side validationInclusione degli script JS<% Html.EnableClientSideValidation(); %>JQuery plug-in, es:JQuery UI (tab, datepicker, …)JQGridAssert.IsTrueLove(EditorTemplates, JQuery)
  • 26. AspNetMvc.More();Esempi:[FX4 only]<%: … %> (equivalente a <% =Html.Encode(…) %>)IoCCustom ActionResult:Generare ThumbnailGenerare Atom/RSS (http://www.ugidotnet.org/Article/Detail/280)“Componentization”: RenderPartial+RenderActionTestAree
  • 28. MVC @ ManagedDesignsIn azienda usiamo il toolkit MVC dalle prime CTP della v1, ed abbiamo raggiunto una struttura «standardizzata» dei progetti:Model 3LayeredExpressionTrees
  • 29. MVC goes Model 3Model 2 separa il Controller in:Front ControllerPage ControllerModel 3 separa il Model in:View Model: rappresenta i dati che la view si impegna a presentare all’utenteWorker Service: è la façade che il page controller utilizza per produrre il View ModelE’ il Single ResponsibilityPrinciple, baby!
  • 30. Nevermind the bollocks, here’s the Model 3
  • 31. LayeredExpressionTrees (LET idiom)Facciamo un gioco: invece di definire un «botto» di DTO, facciamo che layer e servizi si scambino degli IQueryable<YourFavouriteDomainEntity>, facendo «emergere» la query e specificando la proiezione solo all’ultimo momento?L’espressione «Capra e cavoli» vi dice niente? 
  • 32. C’mon Query LET’s go party (ah-ah-ah, yeah!)
  • 33. Slide e demoSlide sul mio blog: http://blogs.ugidotnet.org/papeDemo su CodePlex: http://nsk.codeplex.com