The JavaScript Promise

[CodeStock 2015 edition]

A Full Stack Nirvana

{{Sponsor slide goes here}}

DOGUHAN ULUCA

 

JavaScript Specialty Lead

Excella Consulting

 

@duluca

techtalkdc.com

JavaScript && Promises?

explainJavaScriptPromises()
    .then(function(result) {
        console.log(result);
        talkAboutFullStackJS();
    });
function explainJSPromises() {
    var deferred = Q.defer();
    //some time consuming op
    return deferred.promise;
}
//time consuming operation
$http.get(`google.com/search?=
    javascript async promises`)
    .then(function(wisdom) {
        deferred.resolve(wisdom);
    });
explainJavaScriptPromises()
    .then(function(result) {
        console.log(result);
        talkAboutFullStackJS();
    });

What is The JavaScript Promise?

ease of use

happiness

effectiveness

  1. idea

  2. JavaScript

  3. ...

  4. profit

stack is key

Presentation

API

Business

Persistence

Best Practices

IDE

Patterns

Libraries

TESTING

What if?

Everything was same or very similar

Same language

No Context Switch

Full Stack Nirvana

Going Full Stack

"[T]he foundation of running node-style code to build powerful server solutions is not going away.

It is the future of the web."

Eran Hammer - WalMart Labs, Web Services Lead

Node-style... what?

thin

fast

non-blocking

modularized

i/o

easy

High Performance

PayPal

Improved response times by 35%

which led to

200% increase in concurrent requests handled

High Levels of Scalability & Stability

WalMart

Node.JS since 2013

WalMart

In 2014

1.5 billion page views

during Black Friday

During 

Black Friday

they chose

to deploy

new features

Maintainability

Malleability

PayPal

2x increase in

developer productivity

Developer Happiness

Skill share

Code share

Same tools

No

Context

Switching

The right syrup can fulfill this promise

stack

syrup

Anatomy of

A Hapi LEBRON

The Right Stack

Angular

Hapi.JS

LevelDB

Browserify

NPM

Max Ogden

Open Web Programmer

http://lebron.technology/

Angular.JS

Hapi.JS

Node.JS

LevelDB

Best Practices

WS

npm

Browserify

mocha && protractor

simple

approachable

Why not something more popular?

Sand bags of complexity

Goal

80% functionality

with 20% of the effort

Mongo

Express

Angular

Node

Mongo

+ Great for large databases

+ ORM features with Mongoose

+ Analytics using Jaspersoft

- Requires major installation

- Infrastructure

LevelDB

+ Fast key, value store

+ No installation

+ No infrastructure

- No ORM

- Only for basic data storage

Express

+ Most supported Node web app framework

+ Lightweight to get off the ground

- No built in error handling

- Can be tedious

Hapi.JS

- Less help available

- Initial boilerplate

+ Consistency

+ Configurability

+ Separate business logic from transport layer

Different libraries

Different contexts

leads to

Dependency Injection

var encrypt = require('encryption');
var guid = require('guid');
...
define(['other-encryption', 
    'other-guid'], 
    function (encrypt, guid) {
    ...
});

Browserify

brings NPM to the browser

var encrypt = require('encryption');
var guid = require('guid');
...

File Structure

 |-Excella.Lean.Api
 |-Excella.Lean.Core
 |---Exceptions
 |---Models
 |-Excella.Lean.Core.Composition
 |---Modules
 |-Excella.Lean.Dal
 |---EntityFramework
 |---Migrations
 |-Excella.Lean.Domain:
 |---Events
 |-----Impl
 |---Shared
 |-----Impl
 |-Excella.Lean.Fakes
 |-Excella.Lean.ServiceReferences
 |-Excella.Lean.Tests
 |---Ui
 |-----ModuleA
 |-------PageObjects
 |-------TestCases
 |-Excella.Lean.Web
 |---Composition
 |---Content
 |-----themes
 |-------base
 |---------images
 |---Controllers
 |---Core
 |---Filters
 |---Images
 |---Models
 |---Script
 |-----app
 |-------core
 |---------helpers
 |-------modules
 |---------baseModule
 |-----------landingPage
 |---------eventsModule
 |-----------eventDetails
 |-----------eventsLanding
 |-----lib
 |-----tests
 |-------core
 |---------helpers
 |-------other
 |---Views
 |-----Aat
 |-----Home
 |-----Shared
 |-app
 |---components
 |---directives
 |---services
 |---styles
 |-node_modules
 |-public
 |---css
 |---favicons
 |---fonts
 |---images
 |---js
 |-server
 |---controllers
 |---models
 |---services
 |-shared
 |-tests

Angular

Separation of concerns

Maximize concurrency

1.4+

Component based architecture

2.0

Standards based Web Components

If you didn't deploy

It never happened

Gulp.js

var gulp = require('gulp');

gulp.task('build-js', function () {
    return gulp.src('app/app.js')
        .pipe(browserify({
            insertGlobals : true,
            debug : !process.env.production || true
        }))
        .pipe(gulp.dest('./public/js'))
});
gulp.task('default', ['build-js']);
gulp.task('watch', function () {
    gulp.watch('./app/**/*.js', ['default']);
});

CodeShip.io

Modulus.io

Dig Deeper

Working Full Stack Example

Real-time

Mobile first

Highly scalable

Open Source

remote-retro-hapi

GitHub.com/ExcellaLabs

angular-starter

hapi-web-server

dev-norms

npmjs.org/~duluca

GitHub.com/duluca

Special Thanks To

Kevin Groat

Alex Hoffman

Emmanuel Apau

Brian Palladino

Thank You!

Presented in JavaScript

The JavaScript Promise

By Doguhan Uluca

The JavaScript Promise

With Agile development becoming more and more wide spread. Developers are expected to know and be able to work the full stack of an application and get things done quickly. Consistent forward flow of features are only possible, if technical impediments are minimal. However, it is very difficult for one person or team to employ best practices across multiple technologies and platforms. For the first time ever it is possible to do full-stack development with a consistent set of tools, using the same language. No more to context switch between front-end and back-end languages, libraries and tools. That is The JavaScript Promise. I've synthesized 'A Hapi LEBRON' stack using Angular, Node, Hapi.JS, LevelDB, Browserify, NPM, Bower and Gulp to simplify the development process. I focused on keeping the barrier to entry low, attempting to break down skill silos and eliminate developer context switching between languages, libraries and tools. Angular and Node together can enable a full-stack JavaScript solution, but it's not trivial to keep the stack straight forward enough for all skill levels. I'd like to talk about how anyone can jump in and start creating complete solutions easily.

  • 10,164