SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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晟 沈
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

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
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
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.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
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
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
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
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Dernier (20)

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
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
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...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
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
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
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
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

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