architecture delphi forget about rad, switch to mvc

17
April 2014 From RAD to MVC Arnaud Bouchez

Upload: arnaud-bouchez

Post on 05-Dec-2014

499 views

Category:

Software


1 download

DESCRIPTION

Introduces MVC design, and Service Oriented Architecture (SOA), in the context of modern Delphi applications and the Open Source Synopse mORMot framework.

TRANSCRIPT

Page 1: Architecture Delphi Forget about RAD, switch to MVC

April 2014

From RAD to MVCArnaud Bouchez

Page 2: Architecture Delphi Forget about RAD, switch to MVC

April 2014

From RAD to MVC

RAD MVC MVVM n-Tier / SOA

From RAD to MVC

Page 3: Architecture Delphi Forget about RAD, switch to MVC

April 2014

Rapid Application Development

Our beloved Delphi WYSIWYG Quick prototyping Less typing Component-based Ownership to handle memory Reusability

From RAD to MVC

Page 4: Architecture Delphi Forget about RAD, switch to MVC

April 2014

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

Page 5: Architecture Delphi Forget about RAD, switch to MVC

April 2014

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

Page 6: Architecture Delphi Forget about RAD, switch to MVC

April 2014

Model-View-Controller (MVC) Architecture pattern which:

isolates "domain logic" (the application logic for the user) from the user interface (input and presentation),

permitting independent development, testing and maintenance of each (separation of concerns)

From RAD to MVC

Page 7: Architecture Delphi Forget about RAD, switch to MVC

April 2014

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

Page 8: Architecture Delphi Forget about RAD, switch to MVC

April 2014

Model-View-Controller (MVC) The Model

Contains all business logic Contains data for the application

(often linked to a database) Contains state of the application

(e.g. what orders a customer has) Notifies the View of state changes

(if possible, e.g. not for stateless views) No knowledge of user interfaces,

so it can be reused

From RAD to MVC

Page 9: Architecture Delphi Forget about RAD, switch to MVC

April 2014

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

Page 10: Architecture Delphi Forget about RAD, switch to MVC

April 2014

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

Page 11: Architecture Delphi Forget about RAD, switch to MVC

April 2014

Model-View-Controller (MVC)

From RAD to MVC

MVC Process

Controller

ModelUse

View

Refresh

Notify updates

Command

Page 12: Architecture Delphi Forget about RAD, switch to MVC

April 2014

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

Page 13: Architecture Delphi Forget about RAD, switch to MVC

April 2014

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 displayedIs re-usable for several views

Controller Listens for, and publishes, events

Provides the logic to display the dataProvides the command code to the ViewModel

From RAD to MVC

Page 14: Architecture Delphi Forget about RAD, switch to MVC

April 2014

MVVM

From RAD to MVC

MVVM Process

Page 15: Architecture Delphi Forget about RAD, switch to MVC

April 2014

MVVM in Delphi

LiveBindings Effective since XE3

DSharp Convention-Over-Configuration interfaces

MGM pattern used in hcOPF Mediator component to bind the UI at

design time

From RAD to MVC

Page 16: Architecture Delphi Forget about RAD, switch to MVC

April 2014

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

Page 17: Architecture Delphi Forget about RAD, switch to MVC

April 2014

From RAD to MVC

Thanks to Bill Meyer for his review

Any feedback is welcome athttp://synopse.info