Web Development: Youre Doing it Wrong Stefan Tilkov, innoQ QCon - - PowerPoint PPT Presentation

web development you re doing it wrong
SMART_READER_LITE
LIVE PREVIEW

Web Development: Youre Doing it Wrong Stefan Tilkov, innoQ QCon - - PowerPoint PPT Presentation

Web Development: Youre Doing it Wrong Stefan Tilkov, innoQ QCon London 2013 Session # 9770 #qconlondon @stilkov Wednesday, March 6, 13 Annoying your users Wednesday, March 6, 13 Forbid the use of the back and forward buttons


slide-1
SLIDE 1

Web Development: You’re Doing it Wrong

Stefan Tilkov, innoQ QCon London 2013

Session # 9770 #qconlondon @stilkov

Wednesday, March 6, 13

slide-2
SLIDE 2

Annoying your users

Wednesday, March 6, 13

slide-3
SLIDE 3

Forbid the use of the back and forward buttons

Wednesday, March 6, 13

slide-4
SLIDE 4

Send them to the home page when they hit “refresh”

Wednesday, March 6, 13

slide-5
SLIDE 5

… or ensure the browser pops up a warning window

Wednesday, March 6, 13

slide-6
SLIDE 6

Make sure they can’t open a second browser window

Wednesday, March 6, 13

slide-7
SLIDE 7

Let them see UI chrome and ads first, content last

Wednesday, March 6, 13

slide-8
SLIDE 8

Make sure they can’t bookmark or send a link

Wednesday, March 6, 13

slide-9
SLIDE 9

Don’t let Google index anything

Wednesday, March 6, 13

slide-10
SLIDE 10

Ensure disabling JavaScript gives them a blank page

Wednesday, March 6, 13

slide-11
SLIDE 11

Things that seem like a good idea, but aren’t

Wednesday, March 6, 13

slide-12
SLIDE 12

Fix HTTP’s basic flaw: its statelessness

Wednesday, March 6, 13

slide-13
SLIDE 13

Go beyond the page model because we’re r/w now

Wednesday, March 6, 13

slide-14
SLIDE 14

Avoid CSS because who understands how it works?

Wednesday, March 6, 13

slide-15
SLIDE 15

Avoid HTML because that’s so 20th century

Wednesday, March 6, 13

slide-16
SLIDE 16

Avoid JavaScript because it’s not for real programmers

Wednesday, March 6, 13

slide-17
SLIDE 17

Extend the client/server model with server push because polling? don’t even …

Wednesday, March 6, 13

slide-18
SLIDE 18

Let’s take a step back

Wednesday, March 6, 13

slide-19
SLIDE 19

Let’s build a generic client runtime Define a protocol so it can work with any server Allow it to mix services from different backends Define a generic, declarative data format Separate content and layout Allow for extensibility with client-side scripting Make it work on any device, with any resolution

Wednesday, March 6, 13

slide-20
SLIDE 20

We’re not done yet

Wednesday, March 6, 13

slide-21
SLIDE 21

Standardize it, with (rough) consensus Ensure there are multiple client, server and intermediary implementations to choose from Have every client OS ship with an implementation of the generic client Let every programming environment support it

Wednesday, March 6, 13

slide-22
SLIDE 22

How hard can it be?

Wednesday, March 6, 13

slide-23
SLIDE 23

Competing with the Web may not be the best idea

Wednesday, March 6, 13

slide-24
SLIDE 24

Web-centric web UIs

Wednesday, March 6, 13

slide-25
SLIDE 25

Server-side components Avoid HTML, JS, CSS Trade Familiarity for Complexity Session-centric ROCA Server-side POSH Client-side components Web-centric Single Page Apps Advanced Client Frameworks Server-side REST APIs

Wednesday, March 6, 13

slide-26
SLIDE 26

ROCA

(Resource-oriented Client Architecture)

Wednesday, March 6, 13

slide-27
SLIDE 27

Make your HTML semantic

Wednesday, March 6, 13

slide-28
SLIDE 28

Minimal load times API usage Accessibility Self-descriptiveness Readability

Wednesday, March 6, 13

slide-29
SLIDE 29

CSS HTML Content Layout

Wednesday, March 6, 13

slide-30
SLIDE 30

schema.org

<div> <h1>Avatar</h1> <span>Director: <span>James Cameron</span> (born August 16, 1954)</span> <span>Science fiction</span> <a href="../movies/avatar-theatrical-trailer.html"</a> </div>

Wednesday, March 6, 13

slide-31
SLIDE 31

schema.org

<div itemscope itemtype="http://schema.org/Movie"> <h1>Avatar</h1> <span>Director: <span>James Cameron</span> (born August 16, 1954)</span> <span>Science fiction</span> <a href="../movies/avatar-theatrical-trailer.html"</a> </div>

Wednesday, March 6, 13

slide-32
SLIDE 32

schema.org

<div itemscope itemtype="http://schema.org/Movie"> <h1 itemprop="name">Avatar</h1> <span>Director: <span itemprop="director">James Cameron</span> (born August 16, 1954)</span> <span itemprop="genre">Science fiction</span> <a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">Trailer</a> </div>

Wednesday, March 6, 13

slide-33
SLIDE 33

Use Javascript unobtrusively

Wednesday, March 6, 13

slide-34
SLIDE 34

<a href="javascript:doSomething();"> Some Link </a>

Wednesday, March 6, 13

slide-35
SLIDE 35

<a href="#"

  • nclick="doSomething();">

Some Link </a>

Wednesday, March 6, 13

slide-36
SLIDE 36

<a href="/some-resource"

  • nclick="doSomething(this.href);">

Some Link </a>

Wednesday, March 6, 13

slide-37
SLIDE 37

<a href="/some-resource" class="whatever"> Some Link </a>

Wednesday, March 6, 13

slide-38
SLIDE 38

$("a.whatever").click(function() { doSomething(this.href); });

+

<a href="/some-resource" class="whatever"> Some Link </a>

Wednesday, March 6, 13

slide-39
SLIDE 39

<div id="tabs"> <ul> <li><a href="#tabs-1">Nunc tincidunt</a></li> <li><a href="#tabs-2">Proin dolor</a></li> <li><a href="#tabs-3">Aenean lacinia</a></li> </ul> <div id="tabs-1"> <p>Proin elit arcu, rutrum commodo, vehicula ...</p> </div> <div id="tabs-2"> <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio ...</p> </div> <div id="tabs-3"> <p>Mauris eleifend est et turpis. Duis id erat ...</p> </div>

$("#tabs").tabs();

+

Wednesday, March 6, 13

slide-40
SLIDE 40

Wednesday, March 6, 13

slide-41
SLIDE 41

CSS HTML Content Layout

Wednesday, March 6, 13

slide-42
SLIDE 42

JavaScript CSS HTML Content Behavior Layout

Wednesday, March 6, 13

slide-43
SLIDE 43

JS component JS glue code HTML

Events Methods

Component 2 Component 3 ... Layout/CSS

styles styles

Server / Backend

Ajax

initializes Base Markup responds with

Wednesday, March 6, 13

slide-44
SLIDE 44

Use URIs to identify a single meaningful concept

Wednesday, March 6, 13

slide-45
SLIDE 45

A

http:/ /.../A

Wednesday, March 6, 13

slide-46
SLIDE 46

A B C

http:/ /.../A

?

Wednesday, March 6, 13

slide-47
SLIDE 47

A

http:/ /.../A

C

http:/ /.../C

B

http:/ /.../B

b c

+ AJAX + CSS

Wednesday, March 6, 13

slide-48
SLIDE 48

A B C

http:/ /.../A

Wednesday, March 6, 13

slide-49
SLIDE 49

Don’t disable Browser Features – use them

Wednesday, March 6, 13

slide-50
SLIDE 50

Multiple tabs & windows Bookmarks Back/Forward/Refresh Personalization Menus

Wednesday, March 6, 13

slide-51
SLIDE 51

Put application logic on the server only

Wednesday, March 6, 13

slide-52
SLIDE 52

Don’t trust your clients RESTful APIs for free Non-browser clients (e.g. Google Crawler)

Wednesday, March 6, 13

slide-53
SLIDE 53

http:/ /googlewebmastercentral.blogspot.com/2009/10/proposal-for-making-ajax-crawlable.html

Wednesday, March 6, 13

slide-54
SLIDE 54

YOU’RE DOING IT WRONG

Wednesday, March 6, 13

slide-55
SLIDE 55

Avoid session state

Wednesday, March 6, 13

slide-56
SLIDE 56

Browser Server

HTML Page

Label Label Label Label Label Label Label Label Submit

Wednesday, March 6, 13

slide-57
SLIDE 57

Browser Server

Label Label Label Next Label Label Label Next Label Label Finish

Session State

Wednesday, March 6, 13

slide-58
SLIDE 58

Browser Server

Label Label Label Next Label Label Label Next Label Label Finish

HTML Page

Label Label Label Label Label Label Label Label Submit

Client State

Wednesday, March 6, 13

slide-59
SLIDE 59

Server

HTML Page

Label Label Label Label Label Label Label Label Submit

HTML Page

Label Label Label Label Label Label Label Label Submit

HTML Page

Label Label Label Label Label Label Label Label Submit

Wednesday, March 6, 13

slide-60
SLIDE 60

ROCA

http:/ /roca-style.org/

Wednesday, March 6, 13

slide-61
SLIDE 61

So why don’t we do this?

Wednesday, March 6, 13

slide-62
SLIDE 62

Obsessive Specialization Disorder

Wednesday, March 6, 13

slide-63
SLIDE 63

interface Resource { Resource(URI u) Response get() Response post(Request r) Response put(Request r) Response delete() Link[] links() Form[] forms() }

generic specific

class MyResource implements Resource { … Response post(Request r) { … } … }

Wednesday, March 6, 13

slide-64
SLIDE 64

Severe Tunneling Fixation

Wednesday, March 6, 13

slide-65
SLIDE 65

simple complex easy hard

Wednesday, March 6, 13

slide-66
SLIDE 66

In summary …

Wednesday, March 6, 13

slide-67
SLIDE 67

Not everything new is good, not everything old is bad. (Surprise.)

Wednesday, March 6, 13

slide-68
SLIDE 68

Learning details of how the web works might be time well spent

Wednesday, March 6, 13

slide-69
SLIDE 69

Working with the web is a lot easier than fighting it

Wednesday, March 6, 13

slide-70
SLIDE 70

Thank you!

Q&A

Stefan Tilkov stefan.tilkov@innoq.com http:/ /www.innoq.com/blog/st/ @stilkov Phone: +49 170 471 2625

innoQ Deutschland GmbH http:/ /www.innoq.com

  • Krischerstr. 100

40789 Monheim am Rhein Germany Phone: +49 2173 3366-0 innoQ Schweiz GmbH info@innoq.com

  • Gewerbestr. 11

CH-6330 Cham Switzerland Phone: +41 41 743 0116

Wednesday, March 6, 13