SlideShare una empresa de Scribd logo
1 de 52
Descargar para leer sin conexión
Software Architecture & Design
 Architecture
 From n-Tier to SOA
 From SOAP to REST
 Technical Debt
 Design
 From SQL to ORM, NoSQL and ODM
 From RAD to MVC
 SOLID principles
 Domain Driven Design (DDD)
Applying patterns on Delphi code using mORMot
Software Architecture & Design
From RAD to MVC
From RAD to MVC
 RAD
 MVC
 MVVM
 n-Tier / SOA
 Web MVC with mORMot
From RAD to MVC
Rapid Application Development
 Our beloved Delphi
 WYSIWYG
 Quick prototyping
 Less typing
 Component-based
 Ownership to handle memory
 Reusability
From RAD to MVC
Rapid Application Development
 HTML# Web programing
 # < 5
 PHP template system
 Run SQL from the template!
 Huge included general purpose library
 Lot of Open Source frameworks
 Easy to setup (LAMP)
From RAD to MVC
Rapid Application Development
 Big Ball of Mud
 Mixes User Interface and logic
 Mixes UI, logic and database
 Modules did not help
 Difficult to maintain and evolve
 Manual testing
 Platform specific (web application?)
 Fat clients (SaaS?)
From RAD to MVC
Rapid Application Development
 To be fair
 Bad programmers write bad code;
Good programmers write good code.
 RAD lets bad programmers write bad code faster;
RAD does NOT cause good programmers to
suddenly start writing badly.
From RAD to MVC
Model-View-Controller (MVC)
 Architecture pattern which:
 Isolates “Domain Logic”
 Application logic for the end-user
 Business logic e.g. for data persistence
 From “User Interface”
 Input and presentation
 Permitting uncoupled
development, testing and maintenance
 Separation of concerns
From RAD to MVC
Model-View-Controller (MVC)
 Model What it is
 Manages the behavior of the data
 View What it looks like
 Renders the model for interaction
 Controller What it does
 Receives User inputs
 Instructs the Model and View
From RAD to MVC
Model-View-Controller (MVC)
 The Model
 Contains all business logic
 Contains data for the application
 Often linked to a database or REST
 Contains state of the application
 e.g. what orders a customer has
 Notifies the View of state changes
 If needed, e.g. not for stateless views
 No knowledge of user interfaces
 So it can be reused
From RAD to MVC
Model-View-Controller (MVC)
 The View
 Generates the user interface
which presents data to the user
 Passive (doesn’t do any processing)
 Many views can use
the same model for different reasons
From RAD to MVC
Model-View-Controller (MVC)
 The Controller
 Receives events from the outside world
 Usually through views
 Interacts with the model
 Displays the appropriate view to the user
From RAD to MVC
Model-View-Controller (MVC)
From RAD to MVC
 MVC Process
Controller
Model
Use
View
Refresh
Notify updates
Command
MVC, MVVM, MVCVM
 MVVM and MVCVM
 Even more uncoupled
 For better testing
 The ViewModel
 May (or not) replace the controller
 Expose data and command objects for the view
 Eases two-way communication
From RAD to MVC
MVVM, MVCVM
 Model
 Holds the actual data
(various context, store or other methods)
 View
 Displays a certain shape of data
Has no idea where the data comes from
 ViewModel
 Holds a certain shape of data and commands
Does not know where the data, or code, comes from or how it is displayed
Is re-usable for several views
 Controller
 Listens for, and publishes, events
Provides the logic to display the data
Provides the command code to the ViewModel
From RAD to MVC
MVVM
From RAD to MVC
 MVVM Process
MVVM UI in Delphi
 LiveBindings
 Effective since XE3
 DSharp / Spring4D
 Convention-Over-Configuration interfaces
 MGM pattern used in hcOPF
 Mediator component to bind the UI at design time
 mORMot
 Mustache Web, SOA app layer (preparing VCL/FMX)
From RAD to MVC
MVVM UI in Delphi
 MVVM in Delphi
Architecting and Building Model View
ViewModel Applications
 by Kouraklis, John
 for the concepts – not really reusable
 There is still some place for tools
 VCL / FMX / LCL / HTML / AJAX compatible stuff
 may be interface-based for the controller/VM definition
 let’s see with other OpenSource authors…
From RAD to MVC
MVC and n-Tier / SOA
From RAD to MVC
Presentation Tier
Application Tier
Business Logic Tier
Data Tier
View
Controller
Model
Client 1 (Delphi) Client 2 (AJAX)
Application Server
DB Server
Presentation Tier
Application Tier
Presentation Tier
Business Logic Tier
Data Tier
Web MVC with mORMot
From RAD to MVC
MVC with mORMot
From RAD to MVC
 View
 Controllers
 Model
MVC Web Apps
From RAD to MVC
 mORMot MVC Web Apps
 Model
 View
 Controller
 RESTful SOA or ORM
 SynMustache
 IMVCApplication
SynMustache Views
From RAD to MVC
 Mustache template system
 Generates HTML, TXT, JSON, …
 Data context as TDocVariant
 UTF-8 JSON
 With extensions
SynMustache Views
From RAD to MVC
 Data Context
{
"header": "Colors",
"items": [
{"name": "red", "first": true, "url": "#Red"},
{"name": "green", "link": true, "url": "#Green"},
{"name": "blue", "link": true, "url": "#Blue"}
],
"empty": true
}
SynMustache Views
From RAD to MVC
 Template
<h1>{{header}}</h1>
{{#items}}
{{#first}}
<li><strong>{{name}}</strong></li>
{{/first}}
{{#link}}
<li><a href="{{url}}">{{name}}</a></li>
{{/link}}
{{/items}}
{{#empty}}
<p>The list is empty.</p>
{{/empty}}
SynMustache Views
From RAD to MVC
 Result
<h1>Colors</h1>
<li><strong>red</strong></li>
<li><a href="#Green">green</a></li>
<li><a href="#Blue">blue</a></li>
<p>The list is empty.</p>
SynMustache Views
From RAD to MVC
 Data Context
{
"header": "Colors",
"items": [
{"name": "red", "first": true, "url": "#Red"},
{"name": "green", "link": true, "url": "#Green"},
{"name": "blue", "link": true, "url": "#Blue"}
],
"empty": true
}
SynMustache Views
From RAD to MVC
 Template
<h1>{{header}}</h1>
{{#items}}
{{#first}}
<li><strong>{{name}}</strong></li>
{{/first}}
{{#link}}
<li><a href="{{url}}">{{name}}</a></li>
{{/link}}
{{/items}}
{{#empty}}
<p>The list is empty.</p>
{{/empty}}
SynMustache Views
From RAD to MVC
 Result
<h1>Colors</h1>
<li><strong>red</strong></li>
<li><a href="#Green">green</a></li>
<li><a href="#Blue">blue</a></li>
<p>The list is empty.</p>
SynMustache Views
From RAD to MVC
 Data Context
{
"header": "Colors",
"items": [
{"name": "red", "first": true, "url": "#Red"},
{"name": "green", "link": true, "url": "#Green"},
{"name": "blue", "link": true, "url": "#Blue"}
],
"empty": true
}
SynMustache Views
From RAD to MVC
 Template
<h1>{{header}}</h1>
{{#items}}
{{#first}}
<li><strong>{{name}}</strong></li>
{{/first}}
{{#link}}
<li><a href="{{url}}">{{name}}</a></li>
{{/link}}
{{/items}}
{{#empty}}
<p>The list is empty.</p>
{{/empty}}
SynMustache Views
From RAD to MVC
 Result
<h1>Colors</h1>
<li><strong>red</strong></li>
<li><a href="#Green">green</a></li>
<li><a href="#Blue">blue</a></li>
<p>The list is empty.</p>
SynMustache Views
From RAD to MVC
 Data Context
{
"header": "Colors",
"items": [
{"name": "red", "first": true, "url": "#Red"},
{"name": "green", "link": true, "url": "#Green"},
{"name": "blue", "link": true, "url": "#Blue"}
],
"empty": true
}
SynMustache Views
From RAD to MVC
 Template
<h1>{{header}}</h1>
{{#items}}
{{#first}}
<li><strong>{{name}}</strong></li>
{{/first}}
{{#link}}
<li><a href="{{url}}">{{name}}</a></li>
{{/link}}
{{/items}}
{{#empty}}
<p>The list is empty.</p>
{{/empty}}
SynMustache Views
From RAD to MVC
 Result
<h1>Colors</h1>
<li><strong>red</strong></li>
<li><a href="#Green">green</a></li>
<li><a href="#Blue">blue</a></li>
<p>The list is empty.</p>
SynMustache Views
From RAD to MVC
 Mustache template system benefits
No RAD, but MVC
 Known and simple pattern
 Rendered by any technology (even on client side)
 Easy integration with responsive CSS (Bootsrap)
 Delegate UI to CSS/HTML experts
 Generates not only HTML but TXT, JSON, …
 Data context allows automated testing
MVC Web Apps
From RAD to MVC
 mORMot MVC Web Apps (n-tier)
 Model
 View
 Controller
 RESTful SOA or ORM
 SynMustache
 IMVCApplication
MVC Web Apps
From RAD to MVC
 View
 Controllers
 Model
MVC Web Apps
From RAD to MVC
 Blog MVC Sample
 Model
 View
 Controller
 RESTful ORM
 SynMustache
 IMVCApplication
MVC Web Apps
From RAD to MVC
 Blog MVC Sample (3-Tier)
 View
 Controller
 Model
 SynMustache
 IMVCApplication
 RESTful ORM
(SOA for bigger projects)
Presentation Tier
Logic Tier
Data Tier
MVC Web Apps
From RAD to MVC
 Blog MVC Sample
 Following Convention Over Configuration pattern
 Model
 View
 Controller
 MVCModel.pas
 *.html
 MVCViewModel.pas
MVC Web Apps
From RAD to MVC
 Define a Controller
IBlogApplication = interface(IMVCApplication)
['{73B27C06-9DB9-45A2-BEDD-2013CFB609D0}']
procedure ArticleView(ID: TID;
var WithComments: boolean; Direction: integer; var Scope: variant;
out Article: TSQLArticle; out Author: variant;
out Comments: TObjectList);
procedure AuthorView(
var ID: TID; out Author: TSQLAuthor; out Articles: variant);
function Login(
const LogonName,PlainPassword: RawUTF8): TMVCAction;
function Logout: TMVCAction;
function ArticleComment(ID: TID; const Title,Comment: RawUTF8): TMVCAction;
function ArticleMatch(const Match: RawUTF8): TMVCAction;
procedure ArticleEdit(var ID: TID; const Title,Content: RawUTF8;
const ValidationError: variant;
out Article: TSQLArticle);
function ArticleCommit(
ID: TID; const Title,Content: RawUTF8): TMVCAction;
end;
MVC Web Apps
From RAD to MVC
 Implement a Controller
/// implements the ViewModel/Controller of this BLOG web site
TBlogApplication = class(TMVCApplication,IBlogApplication)
protected
...
public
procedure Default(var Scope: variant);
procedure ArticleView(ID: TID;
var WithComments: boolean; Direction: integer; var Scope: variant;
out Article: TSQLArticle; out Author: variant;
out Comments: TObjectList);
procedure AuthorView(
var ID: TID; out Author: TSQLAuthor; out Articles: variant);
...
MVC Web Apps
From RAD to MVC
 Define a Controller
IBlogApplication = interface(IMVCApplication)
['{73B27C06-9DB9-45A2-BEDD-2013CFB609D0}']
...
procedure AuthorView(
var ID: TID; out Author: TSQLAuthor; out Articles: variant);
...
end;
MVC Web Apps
From RAD to MVC
 Implement a Controller
procedure TBlogApplication.AuthorView(var ID: integer;
out Author: TSQLAuthor; out Articles: variant);
 Method name identifies:
 The input URI (with parameters)
/blog/AuthorView?ID=..[integer]..
 The output template
AuthorView.html
MVC Web Apps
From RAD to MVC
Implement a Controller
procedure TBlogApplication.AuthorView(var ID: integer;
out Author: TSQLAuthor; out Articles: variant);
begin
RestModel.Retrieve(ID,Author);
Author.HashedPassword := ''; // no need to publish it
if Author.ID<>0 then
Articles := RestModel.RetrieveDocVariantArray(
TSQLArticle,'','Author=? order by RowId desc limit 50',[ID],ARTICLE_FIELDS) else
raise EMVCApplication.CreateGotoError(HTML_NOTFOUND);
end;
MVC Web Apps
From RAD to MVC
 Implement a Controller
procedure TBlogApplication.AuthorView(var ID: integer;
out Author: TSQLAuthor; out Articles: variant);
 const from web client to controller in
 out from controller to view out
 var from web client to controller, in and out
and from controller to view
MVC Web Apps
From RAD to MVC
 Implement a Controller
 /blog/AuthorView?ID=123
procedure TBlogApplication.AuthorView(var ID: integer;
out Author: TSQLAuthor; out Articles: variant);
begin
// here ID = 123
RestModel.Retrieve(ID,Author);
Author.HashedPassword := ''; // no need to publish it
 Input parameters are taken from the URI
 And transmitted to the Controller method
MVC Web Apps
From RAD to MVC
 Implement a Controller
procedure TBlogApplication.AuthorView(var ID: integer;
out Author: TSQLAuthor; out Articles: variant);
begin
RestModel.Retrieve(ID,Author);
Author.HashedPassword := ''; // no need to publish it
if Author.ID<>0 then
Articles := RestModel.RetrieveDocVariantArray(
TSQLArticle,'','Author=? order by RowId desc limit 50',[ID],ARTICLE_FIELDS) else
raise EMVCApplication.CreateGotoError(HTML_NOTFOUND);
end;
 {{ID}} {{Author}} {{Articles}}
in the Mustache Data Context
MVC Web Apps
From RAD to MVC
 Implement a Controller
procedure TBlogApplication.AuthorView(var ID: integer;
out Author: TSQLAuthor; out Articles: variant);
http://localhost:8092/blog/mvc-info
→ /blog/AuthorView?ID=..[integer]..
 {{Main}}: variant
 {{ID}}: integer
 {{Author}}: TSQLAuthor
 {{Articles}}: variant
MVC Web Apps
From RAD to MVC
 Sample 30 URIs
 http://localhost:8092/blog/default
 http://localhost:8092/blog/mvc-info
 http://localhost:8092/blog/articleView?id=99
 http://localhost:8092/blog/articleView/json?id=99
 http://localhost:8092/blog/authorView?id=1
From RAD to MVC

Más contenido relacionado

La actualidad más candente

Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overviewbwullems
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - IntroductionRandy Connolly
 
IBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons LearnedIBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons LearnedTed Leung
 
Spring transaction management
Spring transaction managementSpring transaction management
Spring transaction managementHarshit Choudhary
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascriptKumar
 
Dao pattern
Dao patternDao pattern
Dao patternciriako
 
Towards Semantic Modeling of Network Physical Devices
Towards Semantic Modeling of Network Physical DevicesTowards Semantic Modeling of Network Physical Devices
Towards Semantic Modeling of Network Physical DevicesTobias Walter
 
Web-Dev Portfolio
Web-Dev PortfolioWeb-Dev Portfolio
Web-Dev Portfolionwbgh
 
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnelEntity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnelukdpe
 
Combining DSLs and Ontologies Using Metamodel Integration
Combining DSLs and Ontologies Using Metamodel IntegrationCombining DSLs and Ontologies Using Metamodel Integration
Combining DSLs and Ontologies Using Metamodel IntegrationTobias Walter
 

La actualidad más candente (20)

C#/.NET Little Wonders
C#/.NET Little WondersC#/.NET Little Wonders
C#/.NET Little Wonders
 
dot NET Framework
dot NET Frameworkdot NET Framework
dot NET Framework
 
VB.net
VB.netVB.net
VB.net
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overview
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
 
IBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons LearnedIBM Solutions '99 XML and Java: Lessons Learned
IBM Solutions '99 XML and Java: Lessons Learned
 
Chapter2
Chapter2Chapter2
Chapter2
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
 
Spring transaction management
Spring transaction managementSpring transaction management
Spring transaction management
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
 
.net framework
.net framework.net framework
.net framework
 
Api and Fluency
Api and FluencyApi and Fluency
Api and Fluency
 
Dao pattern
Dao patternDao pattern
Dao pattern
 
C O R B A Unit 4
C O R B A    Unit 4C O R B A    Unit 4
C O R B A Unit 4
 
Towards Semantic Modeling of Network Physical Devices
Towards Semantic Modeling of Network Physical DevicesTowards Semantic Modeling of Network Physical Devices
Towards Semantic Modeling of Network Physical Devices
 
Java script
Java scriptJava script
Java script
 
Web-Dev Portfolio
Web-Dev PortfolioWeb-Dev Portfolio
Web-Dev Portfolio
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnelEntity Framework 4 In Microsoft Visual Studio 2010 - ericnel
Entity Framework 4 In Microsoft Visual Studio 2010 - ericnel
 
Combining DSLs and Ontologies Using Metamodel Integration
Combining DSLs and Ontologies Using Metamodel IntegrationCombining DSLs and Ontologies Using Metamodel Integration
Combining DSLs and Ontologies Using Metamodel Integration
 

Destacado

Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Arnaud Bouchez
 
Ekon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiEkon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiArnaud Bouchez
 
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Arnaud Bouchez
 
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotDelphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotArnaud Bouchez
 
A Performance Comparison Of C# 2013, Delphi Xe6, And Python 3.4 Languages
A Performance Comparison Of C# 2013, Delphi Xe6, And Python 3.4 LanguagesA Performance Comparison Of C# 2013, Delphi Xe6, And Python 3.4 Languages
A Performance Comparison Of C# 2013, Delphi Xe6, And Python 3.4 Languagesijpla
 

Destacado (6)

Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference
 
2016 mORMot
2016 mORMot2016 mORMot
2016 mORMot
 
Ekon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiEkon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop Delphi
 
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
Ekon20 mORMot Legacy Code Technical Debt Delphi Conference
 
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotDelphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
 
A Performance Comparison Of C# 2013, Delphi Xe6, And Python 3.4 Languages
A Performance Comparison Of C# 2013, Delphi Xe6, And Python 3.4 LanguagesA Performance Comparison Of C# 2013, Delphi Xe6, And Python 3.4 Languages
A Performance Comparison Of C# 2013, Delphi Xe6, And Python 3.4 Languages
 

Similar a A4 from rad to mvc

ASP.NET MVC From The Ground Up
ASP.NET MVC From The Ground UpASP.NET MVC From The Ground Up
ASP.NET MVC From The Ground UpKevin Griffin
 
MVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetMVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetIndiandotnet
 
Mvvm pattern
Mvvm patternMvvm pattern
Mvvm patternmsarangam
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesAaron Jacobson
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To MvcVolkan Uzun
 
Presentation Thesis
Presentation ThesisPresentation Thesis
Presentation ThesisNaim Latifi
 
Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Shiju Varghese
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overviewSergey Seletsky
 
Programming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCProgramming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCIan Carnaghan
 
ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)Hatem Hamad
 
Lecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdfLecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdfLê Thưởng
 
Web Development Today
Web Development TodayWeb Development Today
Web Development Todaybretticus
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
MVC for Desktop Application - Part 2
MVC for Desktop Application - Part  2MVC for Desktop Application - Part  2
MVC for Desktop Application - Part 2晟 沈
 

Similar a A4 from rad to mvc (20)

ASP.NET MVC From The Ground Up
ASP.NET MVC From The Ground UpASP.NET MVC From The Ground Up
ASP.NET MVC From The Ground Up
 
MVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetMVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - Indiandotnet
 
Mvvm pattern
Mvvm patternMvvm pattern
Mvvm pattern
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
Presentation Thesis
Presentation ThesisPresentation Thesis
Presentation Thesis
 
Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0
 
Asp.netmvc handson
Asp.netmvc handsonAsp.netmvc handson
Asp.netmvc handson
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overview
 
MVC & backbone.js
MVC & backbone.jsMVC & backbone.js
MVC & backbone.js
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
Programming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCProgramming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVC
 
ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Lecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdfLecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdf
 
Web Development Today
Web Development TodayWeb Development Today
Web Development Today
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
MVC for Desktop Application - Part 2
MVC for Desktop Application - Part  2MVC for Desktop Application - Part  2
MVC for Desktop Application - Part 2
 

Más de Arnaud Bouchez

EKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfEKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfArnaud Bouchez
 
EKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfEKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfArnaud Bouchez
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsArnaud Bouchez
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyArnaud Bouchez
 
Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Arnaud Bouchez
 
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotEkon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotArnaud Bouchez
 
Ekon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignEkon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignArnaud Bouchez
 
High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)Arnaud Bouchez
 
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Arnaud Bouchez
 
Ekon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAEkon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAArnaud Bouchez
 
Ekon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven DesignEkon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven DesignArnaud Bouchez
 

Más de Arnaud Bouchez (12)

EKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfEKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdf
 
EKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfEKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdf
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side Notifications
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 Cryptography
 
Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2
 
Ekon24 mORMot 2
Ekon24 mORMot 2Ekon24 mORMot 2
Ekon24 mORMot 2
 
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotEkon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
 
Ekon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignEkon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-Design
 
High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)
 
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
 
Ekon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAEkon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOA
 
Ekon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven DesignEkon21 Microservices - Event Driven Design
Ekon21 Microservices - Event Driven Design
 

Último

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Último (20)

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

A4 from rad to mvc

  • 1. Software Architecture & Design  Architecture  From n-Tier to SOA  From SOAP to REST  Technical Debt  Design  From SQL to ORM, NoSQL and ODM  From RAD to MVC  SOLID principles  Domain Driven Design (DDD) Applying patterns on Delphi code using mORMot Software Architecture & Design
  • 3. From RAD to MVC  RAD  MVC  MVVM  n-Tier / SOA  Web MVC with mORMot From RAD to MVC
  • 4. Rapid Application Development  Our beloved Delphi  WYSIWYG  Quick prototyping  Less typing  Component-based  Ownership to handle memory  Reusability From RAD to MVC
  • 5. Rapid Application Development  HTML# Web programing  # < 5  PHP template system  Run SQL from the template!  Huge included general purpose library  Lot of Open Source frameworks  Easy to setup (LAMP) From RAD to MVC
  • 6. Rapid Application Development  Big Ball of Mud  Mixes User Interface and logic  Mixes UI, logic and database  Modules did not help  Difficult to maintain and evolve  Manual testing  Platform specific (web application?)  Fat clients (SaaS?) From RAD to MVC
  • 7. Rapid Application Development  To be fair  Bad programmers write bad code; Good programmers write good code.  RAD lets bad programmers write bad code faster; RAD does NOT cause good programmers to suddenly start writing badly. From RAD to MVC
  • 8. Model-View-Controller (MVC)  Architecture pattern which:  Isolates “Domain Logic”  Application logic for the end-user  Business logic e.g. for data persistence  From “User Interface”  Input and presentation  Permitting uncoupled development, testing and maintenance  Separation of concerns From RAD to MVC
  • 9. Model-View-Controller (MVC)  Model What it is  Manages the behavior of the data  View What it looks like  Renders the model for interaction  Controller What it does  Receives User inputs  Instructs the Model and View From RAD to MVC
  • 10. Model-View-Controller (MVC)  The Model  Contains all business logic  Contains data for the application  Often linked to a database or REST  Contains state of the application  e.g. what orders a customer has  Notifies the View of state changes  If needed, e.g. not for stateless views  No knowledge of user interfaces  So it can be reused From RAD to MVC
  • 11. Model-View-Controller (MVC)  The View  Generates the user interface which presents data to the user  Passive (doesn’t do any processing)  Many views can use the same model for different reasons From RAD to MVC
  • 12. Model-View-Controller (MVC)  The Controller  Receives events from the outside world  Usually through views  Interacts with the model  Displays the appropriate view to the user From RAD to MVC
  • 13. Model-View-Controller (MVC) From RAD to MVC  MVC Process Controller Model Use View Refresh Notify updates Command
  • 14. MVC, MVVM, MVCVM  MVVM and MVCVM  Even more uncoupled  For better testing  The ViewModel  May (or not) replace the controller  Expose data and command objects for the view  Eases two-way communication From RAD to MVC
  • 15. MVVM, MVCVM  Model  Holds the actual data (various context, store or other methods)  View  Displays a certain shape of data Has no idea where the data comes from  ViewModel  Holds a certain shape of data and commands Does not know where the data, or code, comes from or how it is displayed Is re-usable for several views  Controller  Listens for, and publishes, events Provides the logic to display the data Provides the command code to the ViewModel From RAD to MVC
  • 16. MVVM From RAD to MVC  MVVM Process
  • 17. MVVM UI in Delphi  LiveBindings  Effective since XE3  DSharp / Spring4D  Convention-Over-Configuration interfaces  MGM pattern used in hcOPF  Mediator component to bind the UI at design time  mORMot  Mustache Web, SOA app layer (preparing VCL/FMX) From RAD to MVC
  • 18. MVVM UI in Delphi  MVVM in Delphi Architecting and Building Model View ViewModel Applications  by Kouraklis, John  for the concepts – not really reusable  There is still some place for tools  VCL / FMX / LCL / HTML / AJAX compatible stuff  may be interface-based for the controller/VM definition  let’s see with other OpenSource authors… From RAD to MVC
  • 19. MVC and n-Tier / SOA From RAD to MVC Presentation Tier Application Tier Business Logic Tier Data Tier View Controller Model Client 1 (Delphi) Client 2 (AJAX) Application Server DB Server Presentation Tier Application Tier Presentation Tier Business Logic Tier Data Tier
  • 20. Web MVC with mORMot From RAD to MVC
  • 21. MVC with mORMot From RAD to MVC  View  Controllers  Model
  • 22. MVC Web Apps From RAD to MVC  mORMot MVC Web Apps  Model  View  Controller  RESTful SOA or ORM  SynMustache  IMVCApplication
  • 23. SynMustache Views From RAD to MVC  Mustache template system  Generates HTML, TXT, JSON, …  Data context as TDocVariant  UTF-8 JSON  With extensions
  • 24. SynMustache Views From RAD to MVC  Data Context { "header": "Colors", "items": [ {"name": "red", "first": true, "url": "#Red"}, {"name": "green", "link": true, "url": "#Green"}, {"name": "blue", "link": true, "url": "#Blue"} ], "empty": true }
  • 25. SynMustache Views From RAD to MVC  Template <h1>{{header}}</h1> {{#items}} {{#first}} <li><strong>{{name}}</strong></li> {{/first}} {{#link}} <li><a href="{{url}}">{{name}}</a></li> {{/link}} {{/items}} {{#empty}} <p>The list is empty.</p> {{/empty}}
  • 26. SynMustache Views From RAD to MVC  Result <h1>Colors</h1> <li><strong>red</strong></li> <li><a href="#Green">green</a></li> <li><a href="#Blue">blue</a></li> <p>The list is empty.</p>
  • 27. SynMustache Views From RAD to MVC  Data Context { "header": "Colors", "items": [ {"name": "red", "first": true, "url": "#Red"}, {"name": "green", "link": true, "url": "#Green"}, {"name": "blue", "link": true, "url": "#Blue"} ], "empty": true }
  • 28. SynMustache Views From RAD to MVC  Template <h1>{{header}}</h1> {{#items}} {{#first}} <li><strong>{{name}}</strong></li> {{/first}} {{#link}} <li><a href="{{url}}">{{name}}</a></li> {{/link}} {{/items}} {{#empty}} <p>The list is empty.</p> {{/empty}}
  • 29. SynMustache Views From RAD to MVC  Result <h1>Colors</h1> <li><strong>red</strong></li> <li><a href="#Green">green</a></li> <li><a href="#Blue">blue</a></li> <p>The list is empty.</p>
  • 30. SynMustache Views From RAD to MVC  Data Context { "header": "Colors", "items": [ {"name": "red", "first": true, "url": "#Red"}, {"name": "green", "link": true, "url": "#Green"}, {"name": "blue", "link": true, "url": "#Blue"} ], "empty": true }
  • 31. SynMustache Views From RAD to MVC  Template <h1>{{header}}</h1> {{#items}} {{#first}} <li><strong>{{name}}</strong></li> {{/first}} {{#link}} <li><a href="{{url}}">{{name}}</a></li> {{/link}} {{/items}} {{#empty}} <p>The list is empty.</p> {{/empty}}
  • 32. SynMustache Views From RAD to MVC  Result <h1>Colors</h1> <li><strong>red</strong></li> <li><a href="#Green">green</a></li> <li><a href="#Blue">blue</a></li> <p>The list is empty.</p>
  • 33. SynMustache Views From RAD to MVC  Data Context { "header": "Colors", "items": [ {"name": "red", "first": true, "url": "#Red"}, {"name": "green", "link": true, "url": "#Green"}, {"name": "blue", "link": true, "url": "#Blue"} ], "empty": true }
  • 34. SynMustache Views From RAD to MVC  Template <h1>{{header}}</h1> {{#items}} {{#first}} <li><strong>{{name}}</strong></li> {{/first}} {{#link}} <li><a href="{{url}}">{{name}}</a></li> {{/link}} {{/items}} {{#empty}} <p>The list is empty.</p> {{/empty}}
  • 35. SynMustache Views From RAD to MVC  Result <h1>Colors</h1> <li><strong>red</strong></li> <li><a href="#Green">green</a></li> <li><a href="#Blue">blue</a></li> <p>The list is empty.</p>
  • 36. SynMustache Views From RAD to MVC  Mustache template system benefits No RAD, but MVC  Known and simple pattern  Rendered by any technology (even on client side)  Easy integration with responsive CSS (Bootsrap)  Delegate UI to CSS/HTML experts  Generates not only HTML but TXT, JSON, …  Data context allows automated testing
  • 37. MVC Web Apps From RAD to MVC  mORMot MVC Web Apps (n-tier)  Model  View  Controller  RESTful SOA or ORM  SynMustache  IMVCApplication
  • 38. MVC Web Apps From RAD to MVC  View  Controllers  Model
  • 39. MVC Web Apps From RAD to MVC  Blog MVC Sample  Model  View  Controller  RESTful ORM  SynMustache  IMVCApplication
  • 40. MVC Web Apps From RAD to MVC  Blog MVC Sample (3-Tier)  View  Controller  Model  SynMustache  IMVCApplication  RESTful ORM (SOA for bigger projects) Presentation Tier Logic Tier Data Tier
  • 41. MVC Web Apps From RAD to MVC  Blog MVC Sample  Following Convention Over Configuration pattern  Model  View  Controller  MVCModel.pas  *.html  MVCViewModel.pas
  • 42. MVC Web Apps From RAD to MVC  Define a Controller IBlogApplication = interface(IMVCApplication) ['{73B27C06-9DB9-45A2-BEDD-2013CFB609D0}'] procedure ArticleView(ID: TID; var WithComments: boolean; Direction: integer; var Scope: variant; out Article: TSQLArticle; out Author: variant; out Comments: TObjectList); procedure AuthorView( var ID: TID; out Author: TSQLAuthor; out Articles: variant); function Login( const LogonName,PlainPassword: RawUTF8): TMVCAction; function Logout: TMVCAction; function ArticleComment(ID: TID; const Title,Comment: RawUTF8): TMVCAction; function ArticleMatch(const Match: RawUTF8): TMVCAction; procedure ArticleEdit(var ID: TID; const Title,Content: RawUTF8; const ValidationError: variant; out Article: TSQLArticle); function ArticleCommit( ID: TID; const Title,Content: RawUTF8): TMVCAction; end;
  • 43. MVC Web Apps From RAD to MVC  Implement a Controller /// implements the ViewModel/Controller of this BLOG web site TBlogApplication = class(TMVCApplication,IBlogApplication) protected ... public procedure Default(var Scope: variant); procedure ArticleView(ID: TID; var WithComments: boolean; Direction: integer; var Scope: variant; out Article: TSQLArticle; out Author: variant; out Comments: TObjectList); procedure AuthorView( var ID: TID; out Author: TSQLAuthor; out Articles: variant); ...
  • 44. MVC Web Apps From RAD to MVC  Define a Controller IBlogApplication = interface(IMVCApplication) ['{73B27C06-9DB9-45A2-BEDD-2013CFB609D0}'] ... procedure AuthorView( var ID: TID; out Author: TSQLAuthor; out Articles: variant); ... end;
  • 45. MVC Web Apps From RAD to MVC  Implement a Controller procedure TBlogApplication.AuthorView(var ID: integer; out Author: TSQLAuthor; out Articles: variant);  Method name identifies:  The input URI (with parameters) /blog/AuthorView?ID=..[integer]..  The output template AuthorView.html
  • 46. MVC Web Apps From RAD to MVC Implement a Controller procedure TBlogApplication.AuthorView(var ID: integer; out Author: TSQLAuthor; out Articles: variant); begin RestModel.Retrieve(ID,Author); Author.HashedPassword := ''; // no need to publish it if Author.ID<>0 then Articles := RestModel.RetrieveDocVariantArray( TSQLArticle,'','Author=? order by RowId desc limit 50',[ID],ARTICLE_FIELDS) else raise EMVCApplication.CreateGotoError(HTML_NOTFOUND); end;
  • 47. MVC Web Apps From RAD to MVC  Implement a Controller procedure TBlogApplication.AuthorView(var ID: integer; out Author: TSQLAuthor; out Articles: variant);  const from web client to controller in  out from controller to view out  var from web client to controller, in and out and from controller to view
  • 48. MVC Web Apps From RAD to MVC  Implement a Controller  /blog/AuthorView?ID=123 procedure TBlogApplication.AuthorView(var ID: integer; out Author: TSQLAuthor; out Articles: variant); begin // here ID = 123 RestModel.Retrieve(ID,Author); Author.HashedPassword := ''; // no need to publish it  Input parameters are taken from the URI  And transmitted to the Controller method
  • 49. MVC Web Apps From RAD to MVC  Implement a Controller procedure TBlogApplication.AuthorView(var ID: integer; out Author: TSQLAuthor; out Articles: variant); begin RestModel.Retrieve(ID,Author); Author.HashedPassword := ''; // no need to publish it if Author.ID<>0 then Articles := RestModel.RetrieveDocVariantArray( TSQLArticle,'','Author=? order by RowId desc limit 50',[ID],ARTICLE_FIELDS) else raise EMVCApplication.CreateGotoError(HTML_NOTFOUND); end;  {{ID}} {{Author}} {{Articles}} in the Mustache Data Context
  • 50. MVC Web Apps From RAD to MVC  Implement a Controller procedure TBlogApplication.AuthorView(var ID: integer; out Author: TSQLAuthor; out Articles: variant); http://localhost:8092/blog/mvc-info → /blog/AuthorView?ID=..[integer]..  {{Main}}: variant  {{ID}}: integer  {{Author}}: TSQLAuthor  {{Articles}}: variant
  • 51. MVC Web Apps From RAD to MVC  Sample 30 URIs  http://localhost:8092/blog/default  http://localhost:8092/blog/mvc-info  http://localhost:8092/blog/articleView?id=99  http://localhost:8092/blog/articleView/json?id=99  http://localhost:8092/blog/authorView?id=1
  • 52. From RAD to MVC