JavaScript UI Architecture: Be all that you can be

35
JavaScript UI Architecture be all that you can be kyle simpson @getify http:// getify.me #jsui #hbjs

description

Most web applications take UI architecture for granted, simply using out-of-the-box offerings from the framework of choice without much thought. This often yields far too complicated templating, data exchange (Ajax), URL routing, validation, etc. CVC (Client-View-Controller) is an alternative, deconstructed, framework-independent approach to building/delivering performant, maintainable web UI.

Transcript of JavaScript UI Architecture: Be all that you can be

Page 1: JavaScript UI Architecture: Be all that you can be

JavaScript UI Architecturebe all that you can be

kyle simpson@getifyhttp://getify.me

#jsui #hbjs

Page 2: JavaScript UI Architecture: Be all that you can be

“everyone is entitled to the their own (wrong) opinion.”

--unknown

Page 3: JavaScript UI Architecture: Be all that you can be

how i(we) got here

Page 4: JavaScript UI Architecture: Be all that you can be

front-end (html/css)

?back-end (logic, db)

Page 5: JavaScript UI Architecture: Be all that you can be

front-end (html/css)

“middle-end”

back-end (logic, db)

(ui architecture)

Page 6: JavaScript UI Architecture: Be all that you can be

ui architecture:how the “server” builds & delivers the presentation layer to the “client”

+how communication happens between the presentation layer and the application

Page 7: JavaScript UI Architecture: Be all that you can be

warning: highly offensive material

Page 8: JavaScript UI Architecture: Be all that you can be

warning: highly offensive material

breaking news: javascript is a first-class language now.

javascript is just soking awesome!

Page 9: JavaScript UI Architecture: Be all that you can be

warning: highly offensive material

javascript is better at ui archiecture than your current application.

javascript doesn’t have to run in the browser to be so awesome.

Page 10: JavaScript UI Architecture: Be all that you can be

what we’re NOT talking about

javascript frameworks application

platformsall-in-one anything

css {display:cool;}<marquee>

<html>

Page 11: JavaScript UI Architecture: Be all that you can be

what we ARE talking about

raw javascript (browser & server)

an alternate “design pattern” to MVC modular everything

howto: make the ui really work for you

templating

DRY

Page 12: JavaScript UI Architecture: Be all that you can be

what problems do we need to solve?

Page 13: JavaScript UI Architecture: Be all that you can be

MVCuh oh!

“i like ‘mvc’, I just don’t like the ‘m’…”

Page 14: JavaScript UI Architecture: Be all that you can be

M + C

<?phpif ($user->IsLoggedInAndCanPublish()) { $user->publish($doc->get()); }?>

Page 15: JavaScript UI Architecture: Be all that you can be

M + V<?phpif (user->IsLoggedInAndCanPublish()) {?>

Welcome back!<?php}?>

Page 16: JavaScript UI Architecture: Be all that you can be

V + C<?phpif (user->IsLoggedInAndCanPublish()) {

$output = $template->create(“loggedin.tmpl”)->html();$ouput .= $template->create(“footer.tmpl”)->html();return $output;

}?>

Page 17: JavaScript UI Architecture: Be all that you can be

DRY

Page 18: JavaScript UI Architecture: Be all that you can be

data validation

Page 19: JavaScript UI Architecture: Be all that you can be

url routing

Page 20: JavaScript UI Architecture: Be all that you can be

so how can we solve these problems?

Page 21: JavaScript UI Architecture: Be all that you can be

MVC (in the browser)

? MVC (on the server)

Page 22: JavaScript UI Architecture: Be all that you can be

MVC (in the browser)

iPad MVC (on the server)

Page 23: JavaScript UI Architecture: Be all that you can be

MVC (in the browser)

MVC (on the server)

Page 24: JavaScript UI Architecture: Be all that you can be

MVC (in the browser)

CVC MVC (on the server)

Page 25: JavaScript UI Architecture: Be all that you can be

CVCclient-view-controller

everything is a client of everything

else

Page 26: JavaScript UI Architecture: Be all that you can be

CVC

data should only be data, not methods

or behavior

Page 27: JavaScript UI Architecture: Be all that you can be

CVC

presentation templates should

not have any application logic

Page 28: JavaScript UI Architecture: Be all that you can be

CVC

code should be able to run anywhere

Page 29: JavaScript UI Architecture: Be all that you can be

CVC

whatever application framework you choose (.NET, Java, RoR, PHP, etc), CVC sits on top of

your application

Page 30: JavaScript UI Architecture: Be all that you can be

client(s)everything is module and a

client of everything else

Page 31: JavaScript UI Architecture: Be all that you can be

view(s)HandlebarJS

Page 32: JavaScript UI Architecture: Be all that you can be

HandlebarJStemplating engine written in javascript that takes simple text templates and combines with json data to output presentation views.

Page 33: JavaScript UI Architecture: Be all that you can be

controller(s)also javascript

url routing, data validation, etc

Page 34: JavaScript UI Architecture: Be all that you can be

ask more questions about your architecture…

…be all that you can be!

Page 35: JavaScript UI Architecture: Be all that you can be

more info

kyle simpson@getifyhttp://getify.me

http://github.com/getify/HandlebarJShttp://speakerrate.com/talks/2062http://www.slideshare.net/shadedecho