SlideShare a Scribd company logo
HÖNNUN OG SMÍÐI HUGBÚNAÐAR 2015
L19 Application Architecture
Agenda
▪ Architecture Considerations
▪ Architecture Decisions
▪ Play Framework Exercise
Architecture Considerations
Three Layers
▪ Presentation Layer for the User Interface
▪ Domain Layer for the domain logic
▪ Data Source Layer for the data access
– Separation of concern
Client
Client
Domain Data Source
Presentation Layer
▪ Consideration
– Separating the Presentation Logic from the Domain Logic
– Simple vs. Rich user interface
– Should content be editable frequently
▪ Content Management System
– View templates with HTML and JS
User Interfaces
▪ Clear separation of concerns is important
– Define the Presentation Logic
– Design the domain layer so the presentation can get the information
needed
– Semantics – or the meaning of things is important
– Presentation logic must avoid making assumptions on the domain –
the semantics should be a part of the domain
• Use Data Transfer Objects to store semantics
Presentation Semantics Domain
Client Types
▪ Native OS Applications
– Windows, iOS, Android, Linux
▪ Embedded
– Run inside Web Browsers
– Flash, Java Applets
▪ Interactive Web Applications
– HTML with JavaScript
▪ HTML Presentation in Browsers
– Simple HTML
Client Types
▪ Mobile is not a client type
– It’s just smaller screen
– Which 60% people hold vertically
▪ People have their phones with them all the time
▪ Check their phone about 110 times per day
Different user motivations
Responsive Web Design
▪ Web pages that automatically adjust to the screen size
– Should be the default design
▪ Problems with RWD
– Does not deal with context
– What would a persons be

looking for when using 

a mobile phone?
– Excuse to avoid apps, when app might be a better choice
App vs. Web
Don’t ask a developer which is better - it’s a management decision
MOBILE WEB MOBILE APP
Using a mobile 

web browser
Downloaded, runs

on native hardware
PROS
Content is indexable
Device independent (almost)
Easier/Faster development & update
Easier to measure
CONS
Connection Dependence
Limited hardware integration
Bandwidth & browser limited UX
PROS
Connection independence
Better hardware integration
Better graphic performance & UX
CONS
Content is not web indexable
Device dependence
More expensive development & update
More complex to measure
Source: moz.com/blog/
Content Delivery
▪ Native, Embedded and Interactive Web Apps
– Require HTTP API call for dynamic content
– For example SOAP, REST with Json or XML
▪ HTML Presentation in Browsers
– Server side generated
Content Type
▪ Static Content such as graphic assets, doesn’t change frequently
▪ Editable Content such as text, layout, mashed-up content, editable by content
owners, frequently
▪ Dynamic Content stored in database and manipulated by the domain logic
Content Management Systems
▪ Content is separated form the Enterprise system
– Managed by CMS software with its own database
– HTTP API calls for dynamic content from the enterprise system
CLIENT
Web Browser
HTML
JavaScript CMS
Enterprise
Application
HTTP/REST/Json
OPERATOR
Editable		
content
Static	
content
Dynamic	
content
Static	
content
Domain Layer
▪ Where is the domain logic?
– Application Servers
– Lightweight Containers
Application Servers
▪ Domain Components are deployed on Application Servers
– Distributed Multi-tiered Applications
– Example:
• Web Servers, EJB Servers
Lightweight Containers
▪ Assemble components from different projects into a cohesive
application
– Wiring is done with “Inversion of Control” - config
– Provide life-cycle management of objects
– Provide context
Web Browser
Native App
Web Server
Web Layer
controllers
view
Lightweight Container
Domain
Layer
Data Source
Layer
DB
Data Source Layer
▪ How to create the mapping from the domain to the Data Source Layer
– Gateways with no domain logic
– Records managed with some domain logic
– Data Mappers
Data Source Layer
▪ Domain Model uses gateway
Domain
Layer
Data
Source
Layer
Object Relational Mapping (ORM)
▪ Use a mapping layer to map between objects and tables
– Mapping a data representation from an object model to a relational
data model with a SQL-based schema
▪ Mapping requires 

metadata
– XML
▪ Authoring and maintaining 

metadata is less work than 

maintaining SQL code
The Big Picture
Client
Domain
Data
Source
CMS
REST
Web
Server DB
The Big Picture with Services
Client
Domain
Data
Source
CMS
REST
Web
Server DB
Domain
Data
Source
REST
Web
Server DB
Frameworks Libraries
Shared
Objects
SERVICE
SERVICE
Architecture Decisions
Advice is a dangerous gift
There are no right answers
“Use the advice to prod your thinking, but don’t use it as a
replacement for your thinking” — Martin Fowler
Three Layers
▪ Presentation Layer for the User Interface
▪ Domain Layer for the domain logic
▪ Data Source Layer for the data access
– What patterns to use?
Presentation
Layer
Domain Data Source
Domain Layer
▪ Transaction Script
▪ Domain Model
▪ Table Module
Domain Layer
▪ Transaction Script
– Procedural
– Encapsulates the logic of each transaction
– Works well for systems that are transactional in nature
▪ Drawbacks
– Does not handle complexity of logic
– Code duplications
Domain Layer
▪ Domain Model
– Works nicely for any type of domain logic
– Flexibility in creating an object oriented classes that use
abstractions and polymorphism
– Beautiful code
▪ Drawbacks
– Learning curve – understanding the model
– Requires skills
– Doesn’t always map easily to relational database
Domain Layer
▪ Table Module
– Works well for data driven applications
– Fits well with relational databases
– Requires Record Set functionality
▪ Drawbacks
– Structured around the database
– Needs tooling support, for example Record Set
– Can become dependent on the environment
Data Source Layer
▪ Data Source for Transaction Script
– Fits well to use the Gateway patterns
– Row Data Gateway or Table Data Gateway
– Depends on the applications
– If the transactions are dealing with each row per transactions, then
Row Data Gateway works
– If working with tables, Table Data Gateway works
Data Source Layer
▪ Data Source for Table Module
– Table Module requires good support from Record Set
– Table Data Gateway fits this well
Data Source Layer
▪ Data Source for Domain Model
– If the Domain Model is fairly simple, and maps the database, Active
Record works well
– If you want to provide abstraction the gateway patterns become
better choice, Row Data Gateway and Table Data Gateway
– If things get more complication and there is need to keep the model
independent from the data source, Data Mapper should be
considered
Model View Controller
▪ For all types MVC architectural patterns applies
▪ Web Frameworks are usually implemented using some sort of 

Front Controller pattern
▪ Each request has an Action or a Controller
▪ Views are handle by Template View
Domain Layer
The Big Picture
Presentation
Layer
Service
Layer
Data Source
Domain
DB
We	have	a	relatively	simple	domain	logic	that	maps	nicely	to	the	
data	schema,	and	we	have	good	tools	for	Record	Set	handling.	
What	Domain	Layer	pattern	would	make	sense?
A) Service	Layer
B) Domain	Model
C) Transaction	Script
D) Table	Module
QUIZ
Play Framework Exercise
Exercise
▪ Design Web Application RuNews
– Front page displays RSS news items
– Content read with ImportContentProcess
– User can sign up and login
Overview
Controller
View
Service Layer
Domain Model
Table Data
Gateway
routes ApplicationConext.xml
users
Signup
As a user, I want to be able to sign up
Registration
Fields: name, username, password, email
Validation:
all fields are required
username must be at least 4 characters
password must be confirmed (typed in twice)
Play setup
43
▪ Project is created: RuNews
– activator new RuNews
– Import in IntelliJ IDEA
▪ Structure
– controllers
– is.ru.honn.news
– views
The Database
▪ Table users
44
CREATE TABLE users
(
id int Identity (1, 1) primary key NOT NULL,
name varchar(128),
username varchar(128) unique,
password varchar(128),
email varchar(128),
)
Application.java
45
package controllers;
import play.*;
import play.mvc.*;
import views.html.*;
public class Application extends Controller
{
public Result index()
{
return ok(index.render());
}
}
index
▪ View is views/index.scala.html
▪ Compiled: views/html/index
46
@main("RuNews") {



<h2>Registration</h2>

<p>

Here you can sign up:

</p>

<p>

<a class="btn" href="@routes.SignupController.blank">Sign up</a>

</p>

}
Routing
▪ conf/routes contains the routing information
# Routes

# This file defines all application routes (Higher priority routes first)

# ~~~~



# Home page

GET / controllers.Application.index()



# Sign Up

GET /signup controllers.SignupController.blank()

POST /signup controllers.SignupController.submit()



GET /users/:username controllers.UserController.getUser(username: String)

GET /userinfo controllers.UserController.blank()



# Map static resources from the /public folder to the /assets URL path

GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)

RuNews Example
▪ User
48
public class User
{
protected int id;
protected String name;
protected String username;
protected String password;
protected String email;
public User()
{
}
public User(int id, String name, String username, String password,
String email)
{
this.id = id;
this.name = name;
this.username = username;
this.password = password;
this.email = email;
}
...
RuNews Example
▪ UserService is a Service Layer interface
▪ UserServiceData contains the implementation
49
public interface UserService

{

public int signup(User user);

public User login(String username, String password);

public User getUser(String username);

public void setUserDataGateway(UserDataGateway userDataGateway);

}
Adding Domain and Data Layers
▪ Domain Layer
– Service Layer in service
– Domain Model (very simple) in
domain
▪ Data Source Layer
– Table Data Gateway
Adding Domain and Data Layers
▪ app.xml added to conf
– data.xml not used
51
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://
www.springframework.org/schema/beans/spring-beans.xsd">



<bean id="userService" class="is.ru.honn.news.service.UserServiceData">

<property name="userDataGateway" ref="userDataGateway"/>

</bean>



<bean id="userDataGateway" class="is.ru.honn.news.data.UserData">

<property name="dataSource" ref="dataSource"/>

</bean>



<bean id="dataSource"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>

<property name="url" value="jdbc:jtds:sqlserver://hrnem.ru.is:1433"/>

<property name="username" value=“###”/>

<property name="password" value=“###”/>

</bean>



</beans>
Adding Domain and Data Layers
▪ Table Data Gateway injected into service
52
public class UserServiceData implements UserService
{
RuDataAccessFactory factory;
UserDataGateway userDataGateway;
public UserServiceData()
{
}
public void setUserDataGateway(UserDataGateway UserDataGateway)
{
this.userDataGateway = UserDataGateway;
}
RuNews Example
▪ SignupController is a Controller
53
package controllers;



import ...

import play.mvc.*;

import play.data.*;



import views.html.signup;

import views.html.summary;



import static play.data.Form.form;



public class SignupController extends Controller

{

final static Form<UserRegistration> signupForm = 

form(UserRegistration.class);

protected ApplicationContext ctx = new
FileSystemXmlApplicationContext("/conf/app.xml");



public Result blank()

{

return ok(signup.render(signupForm));

}
RuNews Example
▪ SignupController is a Controller
54
public Result submit()

{

Form<UserRegistration> filledForm = signupForm.bindFromRequest();



if (!"true".equals(filledForm.field("accept").value()))

{

filledForm.reject("accept", "You must accept the terms and conditions");

}

...

if (filledForm.hasErrors())

{

return badRequest(signup.render(filledForm));

}

else

{

UserRegistration created = filledForm.get();

UserService service = (UserService) ctx.getBean("userService");

service.signup(created);

return ok(summary.render(created));

}

}
RuNews Example
▪ signup.scala.html is the view
55
@(signupForm: Form[is.ru.honn.news.domain.UserRegistration])



@import helper._



@main("Signup", nav = "signup") {

@helper.form(action = routes.SignupController.submit) {

<fieldset>

<legend>Account informations</legend>

@inputText(

signupForm("name"),

'_label -> "Name",

'_help -> "Please enter your name.",

'_error -> signupForm.globalError

)

@inputText(

signupForm("username"),

'_label -> "Username",

'_help -> "Please choose a valid username.",

'_error -> signupForm.globalError

)
@inputText(

signupForm("email"), '_label -> "Email",

'_help -> "Enter a valid email address."

)


RuNews Example
▪ summary.scala.html displayes the user
56
@(user: is.ru.honn.news.domain.User)



@main("Account created!", nav = "signup") {



<h2>Your account:</h2>

<p>Name: @user.getName()</p>

<p>Username: @user.getUsername()</p>

<p>Email: @user.getEmail()</p>

}
RuNews Example
▪ index.scala.html is default “/“ view
▪ All views use @main with title as parameter
57
@main("RuNews") {



<h2>Registration</h2>

<p>

Here you can sign up:

</p>

<p>

<a class="btn" href="@routes.SignupController.blank">Sign up</a>

</p>

}
RuNews Example
▪ main.scala.html is layout template
58
@(title: String = "Welcome", nav: String = "")(content: Html)



<!DOCTYPE html>



<html>

<head>

<title>RuNews</title>

<link rel="stylesheet" media="screen"

href="@routes.Assets.versioned("stylesheets/bootstrap.css")">

<link rel="stylesheet" media="screen"

href="@routes.Assets.versioned("stylesheets/main.css")">

<link rel="shortcut icon" type="image/png"

href="@routes.Assets.versioned("images/favicon.png")">

</head>

RuNews Example
▪ main.scala.html is layout template
<body>

<nav class="navbar navbar-default">

<div class="container-fluid">

<div class="navbar-header">

<a class="navbar-brand" href="@routes.Application.index()">RuNews</a>

</div>

<div>

<ul class="nav navbar-nav">

<li class="@("active".when(nav == "signup"))">

<a href="@routes.SignupController.blank">Sign up</a>

</li>

<li class="@("active".when(nav == "details"))">

<a href="@routes.UserController.blank">User details</a>

</li>

</ul>

</div>

</div>

</nav>

RuNews Example
▪ main.scala.html is layout template
<div class="container">

<div class="content">

<div class="page-header">

<h1>@title</h1>

</div>

<div class="row">

<div class="span14">

@content

</div>

</div>

</div>

<footer>

<p>

<a href="http://www.playframework.org">www.playframework.org</a>

</p>

</footer>

</div>

</body>

</html>


L19 Application Architecture
L19 Application Architecture
L19 Application Architecture
L19 Application Architecture
L19 Application Architecture

More Related Content

What's hot

L20 Scalability
L20 ScalabilityL20 Scalability
L20 Scalability
Ólafur Andri Ragnarsson
 
L12 Session State and Distributation Strategies
L12 Session State and Distributation StrategiesL12 Session State and Distributation Strategies
L12 Session State and Distributation Strategies
Ólafur Andri Ragnarsson
 
Nyc hadoop meetup introduction to h base
Nyc hadoop meetup   introduction to h baseNyc hadoop meetup   introduction to h base
Nyc hadoop meetup introduction to h base
智杰 付
 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
Sujit Kumar
 
NoSQLDatabases
NoSQLDatabasesNoSQLDatabases
NoSQLDatabases
Adi Challa
 
SQLDay2013_ChrisWebb_CubeDesign&PerformanceTuning
SQLDay2013_ChrisWebb_CubeDesign&PerformanceTuningSQLDay2013_ChrisWebb_CubeDesign&PerformanceTuning
SQLDay2013_ChrisWebb_CubeDesign&PerformanceTuning
Polish SQL Server User Group
 
8 application servers_v2
8 application servers_v28 application servers_v2
8 application servers_v2
ashish61_scs
 
The Evolution of the Webbroadcast
The Evolution of the WebbroadcastThe Evolution of the Webbroadcast
The Evolution of the Webbroadcast
Jason Bengtson
 
Geek Sync | Successfully Migrating Existing Databases to Azure SQL Database
Geek Sync | Successfully Migrating Existing Databases to Azure SQL DatabaseGeek Sync | Successfully Migrating Existing Databases to Azure SQL Database
Geek Sync | Successfully Migrating Existing Databases to Azure SQL Database
IDERA Software
 
L21 scalability
L21 scalabilityL21 scalability
L21 scalability
Ólafur Andri Ragnarsson
 
Improve Internet Efficiency With EPiServer Portal Framework
Improve Internet Efficiency With EPiServer Portal FrameworkImprove Internet Efficiency With EPiServer Portal Framework
Improve Internet Efficiency With EPiServer Portal Framework
Martin Edenström MKSE.com
 

What's hot (11)

L20 Scalability
L20 ScalabilityL20 Scalability
L20 Scalability
 
L12 Session State and Distributation Strategies
L12 Session State and Distributation StrategiesL12 Session State and Distributation Strategies
L12 Session State and Distributation Strategies
 
Nyc hadoop meetup introduction to h base
Nyc hadoop meetup   introduction to h baseNyc hadoop meetup   introduction to h base
Nyc hadoop meetup introduction to h base
 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
 
NoSQLDatabases
NoSQLDatabasesNoSQLDatabases
NoSQLDatabases
 
SQLDay2013_ChrisWebb_CubeDesign&PerformanceTuning
SQLDay2013_ChrisWebb_CubeDesign&PerformanceTuningSQLDay2013_ChrisWebb_CubeDesign&PerformanceTuning
SQLDay2013_ChrisWebb_CubeDesign&PerformanceTuning
 
8 application servers_v2
8 application servers_v28 application servers_v2
8 application servers_v2
 
The Evolution of the Webbroadcast
The Evolution of the WebbroadcastThe Evolution of the Webbroadcast
The Evolution of the Webbroadcast
 
Geek Sync | Successfully Migrating Existing Databases to Azure SQL Database
Geek Sync | Successfully Migrating Existing Databases to Azure SQL DatabaseGeek Sync | Successfully Migrating Existing Databases to Azure SQL Database
Geek Sync | Successfully Migrating Existing Databases to Azure SQL Database
 
L21 scalability
L21 scalabilityL21 scalability
L21 scalability
 
Improve Internet Efficiency With EPiServer Portal Framework
Improve Internet Efficiency With EPiServer Portal FrameworkImprove Internet Efficiency With EPiServer Portal Framework
Improve Internet Efficiency With EPiServer Portal Framework
 

Similar to L19 Application Architecture

L11 Application Architecture
L11 Application ArchitectureL11 Application Architecture
L11 Application Architecture
Ólafur Andri Ragnarsson
 
Introduction and Basics to web technology .pptx
Introduction and Basics to web technology .pptxIntroduction and Basics to web technology .pptx
Introduction and Basics to web technology .pptx
LEENASAHU42
 
L17 Data Source Layer
L17 Data Source LayerL17 Data Source Layer
L17 Data Source Layer
Ólafur Andri Ragnarsson
 
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & TableauBig Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Sam Palani
 
SharePoint 2013 - What's New
SharePoint 2013 - What's NewSharePoint 2013 - What's New
SharePoint 2013 - What's New
AdventosConsulting
 
L13 Oranizing Domain Logic
L13 Oranizing Domain LogicL13 Oranizing Domain Logic
L13 Oranizing Domain Logic
Ólafur Andri Ragnarsson
 
Webinar How to Achieve True Scalability in SaaS Applications
Webinar How to Achieve True Scalability in SaaS ApplicationsWebinar How to Achieve True Scalability in SaaS Applications
Webinar How to Achieve True Scalability in SaaS Applications
Techcello
 
Serverless_with_MongoDB
Serverless_with_MongoDBServerless_with_MongoDB
Serverless_with_MongoDB
Amazon Web Services
 
AMIS OOW Review 2012 - Deel 7 - Lucas Jellema
AMIS OOW Review 2012 - Deel 7 - Lucas JellemaAMIS OOW Review 2012 - Deel 7 - Lucas Jellema
AMIS OOW Review 2012 - Deel 7 - Lucas Jellema
Getting value from IoT, Integration and Data Analytics
 
Enterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRMEnterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRM
Daniel Cai
 
Lecture 9: Dynamic web application
Lecture 9: Dynamic web applicationLecture 9: Dynamic web application
Lecture 9: Dynamic web application
Artificial Intelligence Institute at UofSC
 
Sap integration with_j_boss_technologies
Sap integration with_j_boss_technologiesSap integration with_j_boss_technologies
Sap integration with_j_boss_technologies
Serge Pagop
 
2014 09-12 lambda-architecture-at-indix
2014 09-12 lambda-architecture-at-indix2014 09-12 lambda-architecture-at-indix
2014 09-12 lambda-architecture-at-indix
Yu Ishikawa
 
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
Mark Rittman
 
Deploying Full BI Platforms to Oracle Cloud
Deploying Full BI Platforms to Oracle CloudDeploying Full BI Platforms to Oracle Cloud
Deploying Full BI Platforms to Oracle Cloud
Mark Rittman
 
SharePoint Custom Development
SharePoint Custom DevelopmentSharePoint Custom Development
SharePoint Custom Development
C/D/H Technology Consultants
 
Assessing technology landscape
Assessing technology landscapeAssessing technology landscape
Assessing technology landscape
Dom Mike
 
L15 Data Source Layer
L15 Data Source LayerL15 Data Source Layer
L15 Data Source Layer
Ólafur Andri Ragnarsson
 
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
Daniel Cai
 
Using Familiar BI Tools and Hadoop to Analyze Enterprise Networks
Using Familiar BI Tools and Hadoop to Analyze Enterprise NetworksUsing Familiar BI Tools and Hadoop to Analyze Enterprise Networks
Using Familiar BI Tools and Hadoop to Analyze Enterprise Networks
MapR Technologies
 

Similar to L19 Application Architecture (20)

L11 Application Architecture
L11 Application ArchitectureL11 Application Architecture
L11 Application Architecture
 
Introduction and Basics to web technology .pptx
Introduction and Basics to web technology .pptxIntroduction and Basics to web technology .pptx
Introduction and Basics to web technology .pptx
 
L17 Data Source Layer
L17 Data Source LayerL17 Data Source Layer
L17 Data Source Layer
 
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & TableauBig Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
 
SharePoint 2013 - What's New
SharePoint 2013 - What's NewSharePoint 2013 - What's New
SharePoint 2013 - What's New
 
L13 Oranizing Domain Logic
L13 Oranizing Domain LogicL13 Oranizing Domain Logic
L13 Oranizing Domain Logic
 
Webinar How to Achieve True Scalability in SaaS Applications
Webinar How to Achieve True Scalability in SaaS ApplicationsWebinar How to Achieve True Scalability in SaaS Applications
Webinar How to Achieve True Scalability in SaaS Applications
 
Serverless_with_MongoDB
Serverless_with_MongoDBServerless_with_MongoDB
Serverless_with_MongoDB
 
AMIS OOW Review 2012 - Deel 7 - Lucas Jellema
AMIS OOW Review 2012 - Deel 7 - Lucas JellemaAMIS OOW Review 2012 - Deel 7 - Lucas Jellema
AMIS OOW Review 2012 - Deel 7 - Lucas Jellema
 
Enterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRMEnterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRM
 
Lecture 9: Dynamic web application
Lecture 9: Dynamic web applicationLecture 9: Dynamic web application
Lecture 9: Dynamic web application
 
Sap integration with_j_boss_technologies
Sap integration with_j_boss_technologiesSap integration with_j_boss_technologies
Sap integration with_j_boss_technologies
 
2014 09-12 lambda-architecture-at-indix
2014 09-12 lambda-architecture-at-indix2014 09-12 lambda-architecture-at-indix
2014 09-12 lambda-architecture-at-indix
 
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
From lots of reports (with some data Analysis) 
to Massive Data Analysis (Wit...
 
Deploying Full BI Platforms to Oracle Cloud
Deploying Full BI Platforms to Oracle CloudDeploying Full BI Platforms to Oracle Cloud
Deploying Full BI Platforms to Oracle Cloud
 
SharePoint Custom Development
SharePoint Custom DevelopmentSharePoint Custom Development
SharePoint Custom Development
 
Assessing technology landscape
Assessing technology landscapeAssessing technology landscape
Assessing technology landscape
 
L15 Data Source Layer
L15 Data Source LayerL15 Data Source Layer
L15 Data Source Layer
 
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
 
Using Familiar BI Tools and Hadoop to Analyze Enterprise Networks
Using Familiar BI Tools and Hadoop to Analyze Enterprise NetworksUsing Familiar BI Tools and Hadoop to Analyze Enterprise Networks
Using Familiar BI Tools and Hadoop to Analyze Enterprise Networks
 

More from Ólafur Andri Ragnarsson

Nýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfaraNýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfara
Ólafur Andri Ragnarsson
 
Nýjast tækni og framtíðin
Nýjast tækni og framtíðinNýjast tækni og framtíðin
Nýjast tækni og framtíðin
Ólafur Andri Ragnarsson
 
New Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionNew Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course Introduction
Ólafur Andri Ragnarsson
 
L01 Introduction
L01 IntroductionL01 Introduction
L01 Introduction
Ólafur Andri Ragnarsson
 
L23 Robotics and Drones
L23 Robotics and Drones L23 Robotics and Drones
L23 Robotics and Drones
Ólafur Andri Ragnarsson
 
L22 Augmented and Virtual Reality
L22 Augmented and Virtual RealityL22 Augmented and Virtual Reality
L22 Augmented and Virtual Reality
Ólafur Andri Ragnarsson
 
L20 Personalised World
L20 Personalised WorldL20 Personalised World
L20 Personalised World
Ólafur Andri Ragnarsson
 
L19 Network Platforms
L19 Network PlatformsL19 Network Platforms
L19 Network Platforms
Ólafur Andri Ragnarsson
 
L18 Big Data and Analytics
L18 Big Data and AnalyticsL18 Big Data and Analytics
L18 Big Data and Analytics
Ólafur Andri Ragnarsson
 
L17 Algorithms and AI
L17 Algorithms and AIL17 Algorithms and AI
L17 Algorithms and AI
Ólafur Andri Ragnarsson
 
L16 Internet of Things
L16 Internet of ThingsL16 Internet of Things
L16 Internet of Things
Ólafur Andri Ragnarsson
 
L14 From the Internet to Blockchain
L14 From the Internet to BlockchainL14 From the Internet to Blockchain
L14 From the Internet to Blockchain
Ólafur Andri Ragnarsson
 
L14 The Mobile Revolution
L14 The Mobile RevolutionL14 The Mobile Revolution
L14 The Mobile Revolution
Ólafur Andri Ragnarsson
 
New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine
Ólafur Andri Ragnarsson
 
L12 digital transformation
L12 digital transformationL12 digital transformation
L12 digital transformation
Ólafur Andri Ragnarsson
 
L10 The Innovator's Dilemma
L10 The Innovator's DilemmaL10 The Innovator's Dilemma
L10 The Innovator's Dilemma
Ólafur Andri Ragnarsson
 
L09 Disruptive Technology
L09 Disruptive TechnologyL09 Disruptive Technology
L09 Disruptive Technology
Ólafur Andri Ragnarsson
 
L09 Technological Revolutions
L09 Technological RevolutionsL09 Technological Revolutions
L09 Technological Revolutions
Ólafur Andri Ragnarsson
 
L07 Becoming Invisible
L07 Becoming InvisibleL07 Becoming Invisible
L07 Becoming Invisible
Ólafur Andri Ragnarsson
 
L06 Diffusion of Innovation
L06 Diffusion of InnovationL06 Diffusion of Innovation
L06 Diffusion of Innovation
Ólafur Andri Ragnarsson
 

More from Ólafur Andri Ragnarsson (20)

Nýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfaraNýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfara
 
Nýjast tækni og framtíðin
Nýjast tækni og framtíðinNýjast tækni og framtíðin
Nýjast tækni og framtíðin
 
New Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionNew Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course Introduction
 
L01 Introduction
L01 IntroductionL01 Introduction
L01 Introduction
 
L23 Robotics and Drones
L23 Robotics and Drones L23 Robotics and Drones
L23 Robotics and Drones
 
L22 Augmented and Virtual Reality
L22 Augmented and Virtual RealityL22 Augmented and Virtual Reality
L22 Augmented and Virtual Reality
 
L20 Personalised World
L20 Personalised WorldL20 Personalised World
L20 Personalised World
 
L19 Network Platforms
L19 Network PlatformsL19 Network Platforms
L19 Network Platforms
 
L18 Big Data and Analytics
L18 Big Data and AnalyticsL18 Big Data and Analytics
L18 Big Data and Analytics
 
L17 Algorithms and AI
L17 Algorithms and AIL17 Algorithms and AI
L17 Algorithms and AI
 
L16 Internet of Things
L16 Internet of ThingsL16 Internet of Things
L16 Internet of Things
 
L14 From the Internet to Blockchain
L14 From the Internet to BlockchainL14 From the Internet to Blockchain
L14 From the Internet to Blockchain
 
L14 The Mobile Revolution
L14 The Mobile RevolutionL14 The Mobile Revolution
L14 The Mobile Revolution
 
New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine
 
L12 digital transformation
L12 digital transformationL12 digital transformation
L12 digital transformation
 
L10 The Innovator's Dilemma
L10 The Innovator's DilemmaL10 The Innovator's Dilemma
L10 The Innovator's Dilemma
 
L09 Disruptive Technology
L09 Disruptive TechnologyL09 Disruptive Technology
L09 Disruptive Technology
 
L09 Technological Revolutions
L09 Technological RevolutionsL09 Technological Revolutions
L09 Technological Revolutions
 
L07 Becoming Invisible
L07 Becoming InvisibleL07 Becoming Invisible
L07 Becoming Invisible
 
L06 Diffusion of Innovation
L06 Diffusion of InnovationL06 Diffusion of Innovation
L06 Diffusion of Innovation
 

Recently uploaded

ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
Jhone kinadey
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Julian Hyde
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
Luigi Fugaro
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
kalichargn70th171
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 

Recently uploaded (20)

ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
Boost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management AppsBoost Your Savings with These Money Management Apps
Boost Your Savings with These Money Management Apps
 
Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)Measures in SQL (SIGMOD 2024, Santiago, Chile)
Measures in SQL (SIGMOD 2024, Santiago, Chile)
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 

L19 Application Architecture

  • 1. HÖNNUN OG SMÍÐI HUGBÚNAÐAR 2015 L19 Application Architecture
  • 2. Agenda ▪ Architecture Considerations ▪ Architecture Decisions ▪ Play Framework Exercise
  • 4. Three Layers ▪ Presentation Layer for the User Interface ▪ Domain Layer for the domain logic ▪ Data Source Layer for the data access – Separation of concern Client Client Domain Data Source
  • 5. Presentation Layer ▪ Consideration – Separating the Presentation Logic from the Domain Logic – Simple vs. Rich user interface – Should content be editable frequently ▪ Content Management System – View templates with HTML and JS
  • 6. User Interfaces ▪ Clear separation of concerns is important – Define the Presentation Logic – Design the domain layer so the presentation can get the information needed – Semantics – or the meaning of things is important – Presentation logic must avoid making assumptions on the domain – the semantics should be a part of the domain • Use Data Transfer Objects to store semantics Presentation Semantics Domain
  • 7. Client Types ▪ Native OS Applications – Windows, iOS, Android, Linux ▪ Embedded – Run inside Web Browsers – Flash, Java Applets ▪ Interactive Web Applications – HTML with JavaScript ▪ HTML Presentation in Browsers – Simple HTML
  • 8. Client Types ▪ Mobile is not a client type – It’s just smaller screen – Which 60% people hold vertically ▪ People have their phones with them all the time ▪ Check their phone about 110 times per day
  • 9.
  • 11. Responsive Web Design ▪ Web pages that automatically adjust to the screen size – Should be the default design ▪ Problems with RWD – Does not deal with context – What would a persons be
 looking for when using 
 a mobile phone? – Excuse to avoid apps, when app might be a better choice
  • 12. App vs. Web Don’t ask a developer which is better - it’s a management decision
  • 13. MOBILE WEB MOBILE APP Using a mobile 
 web browser Downloaded, runs
 on native hardware PROS Content is indexable Device independent (almost) Easier/Faster development & update Easier to measure CONS Connection Dependence Limited hardware integration Bandwidth & browser limited UX PROS Connection independence Better hardware integration Better graphic performance & UX CONS Content is not web indexable Device dependence More expensive development & update More complex to measure Source: moz.com/blog/
  • 14. Content Delivery ▪ Native, Embedded and Interactive Web Apps – Require HTTP API call for dynamic content – For example SOAP, REST with Json or XML ▪ HTML Presentation in Browsers – Server side generated
  • 15. Content Type ▪ Static Content such as graphic assets, doesn’t change frequently ▪ Editable Content such as text, layout, mashed-up content, editable by content owners, frequently ▪ Dynamic Content stored in database and manipulated by the domain logic
  • 16. Content Management Systems ▪ Content is separated form the Enterprise system – Managed by CMS software with its own database – HTTP API calls for dynamic content from the enterprise system CLIENT Web Browser HTML JavaScript CMS Enterprise Application HTTP/REST/Json OPERATOR Editable content Static content Dynamic content Static content
  • 17. Domain Layer ▪ Where is the domain logic? – Application Servers – Lightweight Containers
  • 18. Application Servers ▪ Domain Components are deployed on Application Servers – Distributed Multi-tiered Applications – Example: • Web Servers, EJB Servers
  • 19. Lightweight Containers ▪ Assemble components from different projects into a cohesive application – Wiring is done with “Inversion of Control” - config – Provide life-cycle management of objects – Provide context Web Browser Native App Web Server Web Layer controllers view Lightweight Container Domain Layer Data Source Layer DB
  • 20. Data Source Layer ▪ How to create the mapping from the domain to the Data Source Layer – Gateways with no domain logic – Records managed with some domain logic – Data Mappers
  • 21. Data Source Layer ▪ Domain Model uses gateway Domain Layer Data Source Layer
  • 22. Object Relational Mapping (ORM) ▪ Use a mapping layer to map between objects and tables – Mapping a data representation from an object model to a relational data model with a SQL-based schema ▪ Mapping requires 
 metadata – XML ▪ Authoring and maintaining 
 metadata is less work than 
 maintaining SQL code
  • 24. The Big Picture with Services Client Domain Data Source CMS REST Web Server DB Domain Data Source REST Web Server DB Frameworks Libraries Shared Objects SERVICE SERVICE
  • 26. Advice is a dangerous gift There are no right answers “Use the advice to prod your thinking, but don’t use it as a replacement for your thinking” — Martin Fowler
  • 27. Three Layers ▪ Presentation Layer for the User Interface ▪ Domain Layer for the domain logic ▪ Data Source Layer for the data access – What patterns to use? Presentation Layer Domain Data Source
  • 28. Domain Layer ▪ Transaction Script ▪ Domain Model ▪ Table Module
  • 29. Domain Layer ▪ Transaction Script – Procedural – Encapsulates the logic of each transaction – Works well for systems that are transactional in nature ▪ Drawbacks – Does not handle complexity of logic – Code duplications
  • 30. Domain Layer ▪ Domain Model – Works nicely for any type of domain logic – Flexibility in creating an object oriented classes that use abstractions and polymorphism – Beautiful code ▪ Drawbacks – Learning curve – understanding the model – Requires skills – Doesn’t always map easily to relational database
  • 31. Domain Layer ▪ Table Module – Works well for data driven applications – Fits well with relational databases – Requires Record Set functionality ▪ Drawbacks – Structured around the database – Needs tooling support, for example Record Set – Can become dependent on the environment
  • 32. Data Source Layer ▪ Data Source for Transaction Script – Fits well to use the Gateway patterns – Row Data Gateway or Table Data Gateway – Depends on the applications – If the transactions are dealing with each row per transactions, then Row Data Gateway works – If working with tables, Table Data Gateway works
  • 33. Data Source Layer ▪ Data Source for Table Module – Table Module requires good support from Record Set – Table Data Gateway fits this well
  • 34. Data Source Layer ▪ Data Source for Domain Model – If the Domain Model is fairly simple, and maps the database, Active Record works well – If you want to provide abstraction the gateway patterns become better choice, Row Data Gateway and Table Data Gateway – If things get more complication and there is need to keep the model independent from the data source, Data Mapper should be considered
  • 35. Model View Controller ▪ For all types MVC architectural patterns applies ▪ Web Frameworks are usually implemented using some sort of 
 Front Controller pattern ▪ Each request has an Action or a Controller ▪ Views are handle by Template View
  • 36. Domain Layer The Big Picture Presentation Layer Service Layer Data Source Domain DB
  • 39. Exercise ▪ Design Web Application RuNews – Front page displays RSS news items – Content read with ImportContentProcess – User can sign up and login
  • 40. Overview Controller View Service Layer Domain Model Table Data Gateway routes ApplicationConext.xml users
  • 41. Signup As a user, I want to be able to sign up Registration Fields: name, username, password, email Validation: all fields are required username must be at least 4 characters password must be confirmed (typed in twice)
  • 42.
  • 43. Play setup 43 ▪ Project is created: RuNews – activator new RuNews – Import in IntelliJ IDEA ▪ Structure – controllers – is.ru.honn.news – views
  • 44. The Database ▪ Table users 44 CREATE TABLE users ( id int Identity (1, 1) primary key NOT NULL, name varchar(128), username varchar(128) unique, password varchar(128), email varchar(128), )
  • 45. Application.java 45 package controllers; import play.*; import play.mvc.*; import views.html.*; public class Application extends Controller { public Result index() { return ok(index.render()); } }
  • 46. index ▪ View is views/index.scala.html ▪ Compiled: views/html/index 46 @main("RuNews") {
 
 <h2>Registration</h2>
 <p>
 Here you can sign up:
 </p>
 <p>
 <a class="btn" href="@routes.SignupController.blank">Sign up</a>
 </p>
 }
  • 47. Routing ▪ conf/routes contains the routing information # Routes
 # This file defines all application routes (Higher priority routes first)
 # ~~~~
 
 # Home page
 GET / controllers.Application.index()
 
 # Sign Up
 GET /signup controllers.SignupController.blank()
 POST /signup controllers.SignupController.submit()
 
 GET /users/:username controllers.UserController.getUser(username: String)
 GET /userinfo controllers.UserController.blank()
 
 # Map static resources from the /public folder to the /assets URL path
 GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)

  • 48. RuNews Example ▪ User 48 public class User { protected int id; protected String name; protected String username; protected String password; protected String email; public User() { } public User(int id, String name, String username, String password, String email) { this.id = id; this.name = name; this.username = username; this.password = password; this.email = email; } ...
  • 49. RuNews Example ▪ UserService is a Service Layer interface ▪ UserServiceData contains the implementation 49 public interface UserService
 {
 public int signup(User user);
 public User login(String username, String password);
 public User getUser(String username);
 public void setUserDataGateway(UserDataGateway userDataGateway);
 }
  • 50. Adding Domain and Data Layers ▪ Domain Layer – Service Layer in service – Domain Model (very simple) in domain ▪ Data Source Layer – Table Data Gateway
  • 51. Adding Domain and Data Layers ▪ app.xml added to conf – data.xml not used 51 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http:// www.springframework.org/schema/beans/spring-beans.xsd">
 
 <bean id="userService" class="is.ru.honn.news.service.UserServiceData">
 <property name="userDataGateway" ref="userDataGateway"/>
 </bean>
 
 <bean id="userDataGateway" class="is.ru.honn.news.data.UserData">
 <property name="dataSource" ref="dataSource"/>
 </bean>
 
 <bean id="dataSource"
 class="org.springframework.jdbc.datasource.DriverManagerDataSource">
 <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
 <property name="url" value="jdbc:jtds:sqlserver://hrnem.ru.is:1433"/>
 <property name="username" value=“###”/>
 <property name="password" value=“###”/>
 </bean>
 
 </beans>
  • 52. Adding Domain and Data Layers ▪ Table Data Gateway injected into service 52 public class UserServiceData implements UserService { RuDataAccessFactory factory; UserDataGateway userDataGateway; public UserServiceData() { } public void setUserDataGateway(UserDataGateway UserDataGateway) { this.userDataGateway = UserDataGateway; }
  • 53. RuNews Example ▪ SignupController is a Controller 53 package controllers;
 
 import ...
 import play.mvc.*;
 import play.data.*;
 
 import views.html.signup;
 import views.html.summary;
 
 import static play.data.Form.form;
 
 public class SignupController extends Controller
 {
 final static Form<UserRegistration> signupForm = 
 form(UserRegistration.class);
 protected ApplicationContext ctx = new FileSystemXmlApplicationContext("/conf/app.xml");
 
 public Result blank()
 {
 return ok(signup.render(signupForm));
 }
  • 54. RuNews Example ▪ SignupController is a Controller 54 public Result submit()
 {
 Form<UserRegistration> filledForm = signupForm.bindFromRequest();
 
 if (!"true".equals(filledForm.field("accept").value()))
 {
 filledForm.reject("accept", "You must accept the terms and conditions");
 }
 ...
 if (filledForm.hasErrors())
 {
 return badRequest(signup.render(filledForm));
 }
 else
 {
 UserRegistration created = filledForm.get();
 UserService service = (UserService) ctx.getBean("userService");
 service.signup(created);
 return ok(summary.render(created));
 }
 }
  • 55. RuNews Example ▪ signup.scala.html is the view 55 @(signupForm: Form[is.ru.honn.news.domain.UserRegistration])
 
 @import helper._
 
 @main("Signup", nav = "signup") {
 @helper.form(action = routes.SignupController.submit) {
 <fieldset>
 <legend>Account informations</legend>
 @inputText(
 signupForm("name"),
 '_label -> "Name",
 '_help -> "Please enter your name.",
 '_error -> signupForm.globalError
 )
 @inputText(
 signupForm("username"),
 '_label -> "Username",
 '_help -> "Please choose a valid username.",
 '_error -> signupForm.globalError
 ) @inputText(
 signupForm("email"), '_label -> "Email",
 '_help -> "Enter a valid email address."
 ) 

  • 56. RuNews Example ▪ summary.scala.html displayes the user 56 @(user: is.ru.honn.news.domain.User)
 
 @main("Account created!", nav = "signup") {
 
 <h2>Your account:</h2>
 <p>Name: @user.getName()</p>
 <p>Username: @user.getUsername()</p>
 <p>Email: @user.getEmail()</p>
 }
  • 57. RuNews Example ▪ index.scala.html is default “/“ view ▪ All views use @main with title as parameter 57 @main("RuNews") {
 
 <h2>Registration</h2>
 <p>
 Here you can sign up:
 </p>
 <p>
 <a class="btn" href="@routes.SignupController.blank">Sign up</a>
 </p>
 }
  • 58. RuNews Example ▪ main.scala.html is layout template 58 @(title: String = "Welcome", nav: String = "")(content: Html)
 
 <!DOCTYPE html>
 
 <html>
 <head>
 <title>RuNews</title>
 <link rel="stylesheet" media="screen"
 href="@routes.Assets.versioned("stylesheets/bootstrap.css")">
 <link rel="stylesheet" media="screen"
 href="@routes.Assets.versioned("stylesheets/main.css")">
 <link rel="shortcut icon" type="image/png"
 href="@routes.Assets.versioned("images/favicon.png")">
 </head>

  • 59. RuNews Example ▪ main.scala.html is layout template <body>
 <nav class="navbar navbar-default">
 <div class="container-fluid">
 <div class="navbar-header">
 <a class="navbar-brand" href="@routes.Application.index()">RuNews</a>
 </div>
 <div>
 <ul class="nav navbar-nav">
 <li class="@("active".when(nav == "signup"))">
 <a href="@routes.SignupController.blank">Sign up</a>
 </li>
 <li class="@("active".when(nav == "details"))">
 <a href="@routes.UserController.blank">User details</a>
 </li>
 </ul>
 </div>
 </div>
 </nav>

  • 60. RuNews Example ▪ main.scala.html is layout template <div class="container">
 <div class="content">
 <div class="page-header">
 <h1>@title</h1>
 </div>
 <div class="row">
 <div class="span14">
 @content
 </div>
 </div>
 </div>
 <footer>
 <p>
 <a href="http://www.playframework.org">www.playframework.org</a>
 </p>
 </footer>
 </div>
 </body>
 </html>