101
Tooling for Modern Web App developer

Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Embed Size (px)

DESCRIPTION

The primary objective of this presentation is to get an idea about end-to-end front-end workflow and useful tools. We will discuss hot tools like Yeoman, Grunt and Bower. But the session is not limited to these tools - we will touch each phase of front-end development like boiler-plating, preprocessors, performance, documentation, code quality, reporting and architecture etc.

Citation preview

Page 1: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Tooling for Modern Web App developer

Page 2: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

About me

Praveen Vijayandecodize.com@praveen_vijaya

Page 3: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Agenda

Page 4: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Javascript CSS HTML

BoilerplateBackboneAngularBackbone + amd

Normalize.css HTML5 BoilerplateMobile BoilerplatesEmailer Boilerplate

Authoring abstractions

CoffeescriptTypescriptDart

SCSSLESSStylus

MarkdownJADEHAML

Frameworks

jQuery, Backbone, Angular, Ember

Bootstrap, Topcoat, Pure, Foundation

Bootstrap, html5 Boilerplate

Iteration workflow

Grunt, Brunch, Yeoman, Codekit, Prepros, Livereload

Performance tuning and code quality

Chrome dev tools, Heap profile, Timeline, Tracing,linting

Frame rateContinuous paintingSelector profileCSSLintRecess

Network panelValidationW3C validatorHTML inspectorDOM Monster

OptimizationUglifyjsClosure compilerr.js

CssminYUI compressor cssoo

HtmlminImage optimization

Shared understanding

YUI DocDocco

KSSStyledocco

Deploy SVN, Git, Travis CI, Jenkins

Page 5: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

TODO Project

Page 6: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan
Page 7: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan
Page 8: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

ModelView

Events

Page 9: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

jQuery never tell how to structure your app

Page 10: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

JS Structure

Your

Page 11: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Model View View Adapter

Str

uct

ure

JS

MV *

Model View Presenter

Model View Controller

Model View ViewController

Model View ViewModel

Page 12: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

ViewData

Page 13: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

View

View

View

Page 14: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Model

Collection

View

Page 15: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

M

V*

Fra

me

wo

rks

MV

* Lib

rary Spine JS

VS

... ...

Page 16: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Scaling backbone apps

Page 17: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Backbone never tell how to create

reusable modules and load it on

demand

Page 18: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Asynchronous Module

Definition (AMD)

Modular Javascript

Page 19: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Mo

du

lar

Java

scrip

t

Purpose Module?Highly decoupled, distinct pieces of functionality stored in modules

Dependency References

Page 20: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Mo

du

lar

Java

scrip

t

Two Steps1. Define module2. Require it

Page 21: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Mo

du

lar

Java

scrip

t

Page 22: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Mo

du

lar

Java

scrip

t

Configuration

Require module

Define module & its dependencies1

2

Page 23: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Mo

du

lar

Java

scrip

t

Combine related scripts together

Minifies it via UglifyJS/ Closure Compiler

Optimize CSS

r.js optimizer

$ node r.js -o baseUrl=. paths.jquery=some/other/jquery name=main out=main-built.js

Page 24: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Mo

du

lar

Java

scrip

t

AMD loaders

curljs

ES6 Module

Page 25: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Test Driven Development

TDD

/ B

DD

Page 26: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

TDD

/ B

DDWhy TDD?

Design your code well

Build confidence to use your code

Don’t let same bug popup twice

Seamless change requests adaption

Automatic Documentation

Continuous Integration

Page 27: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Fail

PassRefactor

TDD

/ B

DD

PROCESS

Page 28: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

TDD

/ B

DDQunit

Fixture

Source file Tests

Page 29: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

TDD

/ B

DDQunit Group test

Test cases

Page 30: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

TDD

/ B

DDQunit

Page 31: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Javascripttranscompiler

https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS

Page 32: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

coffeescript

Page 33: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

typescript

Page 34: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Performance tuning

&Optimization

Page 35: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Javascript lint

Code Quality Tools for detecting potential problem in your javascript

Page 36: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Chrome dev tool

Timeline

Page 37: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Chrome dev tool

Profiling

Page 38: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Chrome dev tool

Tracing chrome://tracing/

Page 39: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

JavaScript performance

http://jsperf.com/ http://dromaeo.com/

Page 40: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Do

cum

en

tatio

nYUI

Natural Docs

Docco

Page 41: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Do

cum

en

tatio

n

Page 42: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Continuous Integration

&Code coverage

Page 43: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Co

de

co

vera

ge

http://jsoverson.github.io/plato/examples/jquery/

Plato

Page 44: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Code coverageplatoistanbuljscoverblanket.jsjscomplexity.org

To

ols

Page 45: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

ContinuousIntegration

Continuous integration – the practice of frequently integrating one's new or changed code with the existing code repository – should occur frequently enough that no intervening window remains between commit and build, and such that no errors can arise without developers noticing them and correcting them immediately

CI

-wikipedia

Page 46: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Travis-ci.org

Tests

Git

pu

sh

Page 47: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Session SummaryStructure your appOptimise itDocument itContinuous integration

Page 48: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

CSS

Page 49: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

CSS Libraries Bootstrap PureFoundationTopcoatinuit

Page 50: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

CSS Preprocessors

Page 51: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

What is CSSPreprocessorsStylesheet meta language that

is interpreted into CSS

$basecolor: #f1f1f1;

body{background: $basecolor

}

body {

background: #f1f1f1;

}

SCSS

CSS

Page 52: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

CSS is Awesome!but Maintaining

:)

:(

Page 53: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

SCSS

Page 54: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

SCSS

partials@import@extend@include@if@for%placeholder@functions etc..

Page 55: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Compiling

Deployment Server Client Local

Compile as part of deployment process (Capistrano, Fabric).

Compile and cache up on request.

Compile using javascript at browser end (not recommended)

Compile using tools.

Page 56: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Tools

Prepros

Page 57: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Online

Tool

s

Page 58: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Preprocessors don't output bad

code, bad developers do

Page 59: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Structure your CSS

Page 60: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

RepetitionMaintainabilityDecouplingSpecificity

WH

Y?

Page 61: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

OOCSSBEMSMACSS

Methodologies

Page 62: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

OOCSSPurpose of OOCSS is to identify common pattern & encourage code reuse

Main principles

Separate structure and skin

Separate container and content

Page 63: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

BEMBlock : A block is an independent entity.

Element : An element is a part of a block that performs a certain function. Blocks and elements constitute page content.

Modifier : Similar block with slightly altered its appearance or behavior..

Page 64: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

SMACSSBase : Base rules are the defaults.

Layout : Divide the page into sections. Layouts hold one or more modules together.

Module : are the reusable, modular parts of our design.

State : are ways to describe how our modules or layouts will look when in a particular state. Is it hidden or expanded?

Theme : are similar to state rules in that they describe how modules or layouts might look.

Page 65: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Living Style guide

Create style guide as you code!!

Page 66: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Gith

ub s

tyle

gui

de

https://github.com/styleguide/css

Page 67: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

KS

S s

tyle

gui

de

/*A button suitable for giving stars to someone.

:hover - Subtle hover highlight..stars-given - A highlight indicating you've already given a star..stars-given:hover - Subtle hover highlight on top of stars-given styling..disabled - Dims the button to indicate it cannot be used.

Styleguide 2.1.3.*/

a.button.star{ ...}a.button.star.stars-given{ ...}a.button.star.disabled{ ...}

Page 68: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

KSSStyledoco

Page 69: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

PerformanceOptimization

Page 70: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Performance

Page 71: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Performance

Page 72: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Performance

Page 73: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Session SummaryBootstrap using librariesStructure your CSSOptimise itDocument it

Page 74: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

HTML

Page 75: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

JADEHAML

Markdown

Page 76: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

JADE

Page 77: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

JADESyntax Filters Code IterationConditionalsTemplate inheritanceBlock append / prependIncludesMixins

Page 78: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Performance optimization

Page 79: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Pe

rfo

rma

nce

op

tim

iza

tio

n

too

lsMinify CSS, HTML, JSConcat CSS, JSOptimise image using optipng, jpegtran etc..

Page 80: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

W3C Validator, HTML InspectorP

erf

orm

an

ce o

pti

miz

ati

on

to

ols

Page 81: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Pe

rfo

rma

nce

op

tim

iza

tio

n

too

lsPagespeedYslowWebpagetestGTMetrixGA

Page 82: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Session SummaryUse templating langs prudently

Measure & Optimize for performance

Validate your code

Page 83: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

ToolingTooling

Page 84: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

YoGruntBower

Page 85: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Lightning-fast scaffolding Great build process Automatically compile CoffeeScript & Compass Automatically lint your scripts Built-in preview server Awesome Image Optimization Killer package management PhantomJS Unit Testing

YeomanIt's a workflow

collection of tools and best practices

Page 86: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Yeoman

Yeoman = Yo + Grunt + Bower

Page 87: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

YeomanInstallnpm install -g yo grunt-cli bowernpm install -g generator-webappyo webapp

Usagegrunt servergrunt testgrunt

Page 88: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Yeoman

Page 89: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Anatomy

Project folder

App folder

Grunt file

Package json

Unit tests

Bower json

Page 90: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Grunt

Page 91: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Gruntfile.js

Config

Tasks

Targets

This file used to configure or define tasks and load grunt plugins

Page 92: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

package.json

Config

This file contain all information about npm packages

Page 93: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Grunt

Page 94: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Grunt

Page 95: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Bower

Page 96: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

A Project

Page 97: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Production Environment

Page 98: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Production Environment

Page 99: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Production Environment

180+ scss files, 550+ jade files

Page 100: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Demo

Page 101: Front end workflow Presentation at Coffee@DBG by Praveen Vijayan

Thanks