17
June 2015 From RAD to MVC Arnaud Bouchez

A4 from rad to mvc

Embed Size (px)

Citation preview

June 2015

From RAD to MVC

Arnaud Bouchez

June 2015

From RAD to MVC

RAD

MVC

MVVM

n-Tier / SOA

From RAD to MVC

June 2015

Rapid Application Development

Our beloved Delphi

WYSIWYG

Quick prototyping

Less typing

Component-based

Ownership to handle memory

Reusability

From RAD to MVC

June 2015

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

June 2015

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

June 2015

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 independent

development, testing and maintenance of each

Separation of concerns

From RAD to MVC

June 2015

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

June 2015

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

June 2015

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

June 2015

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

June 2015

Model-View-Controller (MVC)

From RAD to MVC

MVC Process

Controller

Model

Use

View

Refresh

Notify updates

Command

June 2015

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

June 2015

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

June 2015

MVVM

From RAD to MVC

MVVM Process

June 2015

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

June 2015

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

June 2015

From RAD to MVC