spa: key questions

30
Single Page Web Application KEY QUESTIONS 1

Upload: volodymyr-voytyshyn

Post on 28-Aug-2014

242 views

Category:

Software


0 download

DESCRIPTION

Key questions that should be resolved when developing a single page web application.

TRANSCRIPT

Page 1: SPA: Key Questions

Single Page Web Application

KEY QUESTIONS

1

Page 2: SPA: Key Questions

2

What arethe key questions

when developing an SPA?

What arethe key questions

when developing an SPA?

Page 3: SPA: Key Questions

What’s an SPA?

1. A page is not completely reloaded

2. HTML is generated by client side JS

3. Client side state is stored with JS objects

3

WebPage

SPA

Complexity

Low

High

Page 4: SPA: Key Questions

.NET Web Evolution3 GENERATION OF ASP.NET APPLICATIONS

4

Page 5: SPA: Key Questions

.NET Web: Generation #1ASP.NET Web Forms / 2002 – Now

5

Page

Web Form Code Behind

Life Cycle

Clien

tS

erv

er

No special JS

structuring

GET / POST

Page 6: SPA: Key Questions

.NET Web: Generation #2ASP.NET MVC / 2009 – Now

6

Page

Controller

Clien

tS

erv

er

PrimitiveJS

structuring

GET / POST

Page 7: SPA: Key Questions

.NET Web: Generation #3ASP.NET Web API / 2012 – Now

7

Page

REST API

Clien

tS

erv

er

StrongJS

structuring

Mobile App

GET / POST / PUT / DELETE

Page 8: SPA: Key Questions

The Key Questions

8

Page 9: SPA: Key Questions

1. Base JS “Bricks”1.1. WHAT IS A MINIMAL STRUCTURAL UNIT?

1.2. HOW TO MANAGE DEPENDENCIES AMONG UNITS?

9

Page 10: SPA: Key Questions

JS Module Pattern

10

Provides both private and publicencapsulation for classes

The Module Pattern (by Addy Osmani)

Page 11: SPA: Key Questions

JS Module Example

11

▪ Closure is used for private state

▪ “Public” object is returned

▪ Created by IIFE

Page 12: SPA: Key Questions

JS Module Dependencies

12

Page 13: SPA: Key Questions

JS Module Extending

13

Page 14: SPA: Key Questions

Pseudo Classas a JS Module

14

Page 15: SPA: Key Questions

Backbone collectionas a JS Module

15

Page 16: SPA: Key Questions

JS Module Standards: AMD

16

define(id?, dependencies?, factory)

AMD Specification (on Git Hub)Writing Modular JavaScript With AMD, CommonJS & ES Harmony (by Addy Osmani)

Page 17: SPA: Key Questions

JS Module Quality Criterion

17

How easily could a JS Module be coveredby UNIT TESTS?

Page 18: SPA: Key Questions

2. Frameworks2.1. WHAT IS A STACK OF BASE FRAMEWORKS?

18

Page 19: SPA: Key Questions

Criteria to Frameworks Stack1. Extending of base JS functions

2. DOM processing

3. HTML templates

4. AJAX / REST handling

5. MV*

6. Routing

7. JS Modules management

19

Page 20: SPA: Key Questions

Top JS MV* Frameworks

20

Knockout.js

Ember.js

Angular.js

Backbone.js

Page 21: SPA: Key Questions

Sample of Frameworks Stack

21

Backbone.js

Underscore.js

jQuery Require.js

Page 22: SPA: Key Questions

3. Architecture3.1. HOW TO STRUCTURE GUI?

3.2. HOW TO KEEP DATA?

3.3. HOW TO PUT THINGS TOGETHER?

22

Page 23: SPA: Key Questions

Web Module

1. Works independently from other web modules

2. Works within the “sandbox”

3. Has limited knowledge regarding the whole application

4. Is managed by a web module manager

23

Scalable JavaScript Application Architecture (by Nicholas Zakas)

Web Module = HTML + CSS + JS

Page 24: SPA: Key Questions

Web Modules: Base Idea

24

Web Module 1 Web Module 2

Web Modules Manager

Manages a web module life cycle

Manages collaboration among modules

Web Module Context Everything a web

module knows about the application

Manage user’s interaction

Don’t know about each other

Web Module↓

an independent part of GUI

Page 25: SPA: Key Questions

Web Modules:Hierarchical Implementation

25

Root Web Module

Web Module 1

Web Module 1-1 Web Module 1-2

Application

Web Module 2

Web Module 2-1 Web Module 2-2

Page 26: SPA: Key Questions

Parent & Child Web Modules

26

Parent

Child

Communication between parent and child

Child's life cycle management

1: Register(context, eventHandlers)

3: Invoke a child's method()

2: Unregister()

4: Raise an event()

Page 27: SPA: Key Questions

Web Module: Quality Criterion

27

How much is a web module depended fromthe other web modules?

Page 28: SPA: Key Questions

Data Aggregate

28

Customer Order

Item

REST API

Web Module 1 Web Module 2

Page 29: SPA: Key Questions

29

Page 30: SPA: Key Questions

Thank You!

30