widening your javascript application

32
Widening your Javascript Application: Organizational Tips from the (Front End) Front Line Alex McPherson +

Upload: alex-mcpherson

Post on 09-May-2015

5.061 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Widening your JavaScript Application

Widening your Javascript Application:

Organizational Tips from the (Front End) Front Line

Alex McPherson

+

Page 2: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Overview

•Should I be here

•Should I trust this guy

•5 types of javascript websites/apps

•When to level up

Page 3: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Should I be here?

•Survey of organization styles

•Mostly non-technical, foundational

•JavaScr-whatnow?-----x---------------------TC39

Page 4: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Who ARE you?

•Alex

•Boulder

•Quick Left

•Manute Bol of JavaScript

•Sublime Text•Railscast Theme•Commas last•ALWAYS put in

semicolons

Page 5: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Manute Bol

Page 6: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Format

•APPLICATION_TYPE

•Example website

•Tools it might leverage

•How to refactor to get to here

•Signs you might want to level up

Page 7: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Write some HTML

When you want to be awesome

None!

Mom’s cat website

Type 0: No JS

Page 8: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Plugins, /lib folder

Plugins++, Editing them

Bootstrap.js

Modals and a carousel

Type 1: Declarative

Page 9: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Landing page

Type 2: $(doc).ready

Page 10: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Simple $(doc).ready

Page 11: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

main.js, /libs

Line count, multiple ready calls

Handwritten javascript!

Landing page

Type 2: $(doc).ready

Page 12: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Small blog

Type 3: Objects

Page 13: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Simple Objects

Page 14: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Folders, 1 global object

Small blog

Type 3: Objects

Page 15: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Obligatory Paul Irish

Page 16: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

doc.readys => .init(), namespace

Cross-dependent classes, tired of DIY, don’t know where to add event bindings

Folders, 1 global object

Small blog

Type 3: Objects

Page 17: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Modules, MVC, templates, build tools

Big data dashboard

Type 4: Modules and MVC

Page 18: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Modules

•AMD or CommonJS (but: AMD)

•Meaningful files of code

•Guaranteed results in the browser

•Encourages better code (I think)

Page 19: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Simple Module

Page 20: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Modules, MVC, templates, build tools

Big data dashboard

Type 4: Modules and MVC

Page 21: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

MVC

•Enhanced organization

•Backbone, Ember, Angular

•Porting DOM soup => Backbone, A++

•Take or leave parts

Page 22: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Modules, MVC, templates, build tools

Big data dashboard

Type 4: Modules and MVC

Page 23: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Templates

Page 24: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Templates

Page 25: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Templates

Page 26: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Templates

•Underscore, jade, mustache, handlebars, dust...

•Precompiling

Page 27: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

Modules, MVC, templates, build tools

Big data dashboard

Type 4: Modules and MVC

Page 28: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Build Tools

•Housekeeping tasks

•Grunt.js

•Task based

•node.js

•‘sprockets-commonjs’ gem

•Take or leave parts

Page 29: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Example:

Tools it might leverage:

How to get here:

When to level up:

One piece at a time!

Something crazy like meteor.js

Modules, MVC, templates, build tools

Big data dashboard

Type 4: Modules and MVC

Page 30: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Overview1. No Javascript

2. Libraries

3. $(document).ready

4. Object based

5. MVC, Modules

Page 31: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Overview

•Rightsized apps are OK

•Don’t always start big, but think about it

•Know when to level up

Page 32: Widening your JavaScript Application

Alex McPherson Quick Left @alexmcpherson

Thanks!

•@alexmcpherson

•Quick Left, Boulder, we’re hiring