5 Steps to Mastering the Art of Seaside

88
www.seaside.st www.lukas-renggli.ch

description

Seaside does things differently from what is considered best practice for Web development. Seaside breaks with common best practices, such as sharing as little state as possible, using clean and carefully chosen URLs, and using templates to separate model and presentation. This tutorial will give a quick introduction to a Web framework that is different by design. It will demonstrate new patterns of Web development, that let you build highly interactive Web applications quickly, reusably and maintainably. Moreover it will show how Seaside integrates with latest technologies such as AJAX and Comet. Lukas Renggli is a core developer of the Seaside web application framework. He has been using Seaside in industrial settings for more than 5 years. Lukas Renggli is the author of several frameworks built on top of Seaside, such as the Pier Content Management System.

Transcript of 5 Steps to Mastering the Art of Seaside

Page 2: 5 Steps to Mastering the Art of Seaside

Lukas Renggli

AcademicsPhD Student, University of Bern

IndustryIndependent Software Consultant

CommunitiesCore-developer of SeasideAuthor of Magritte and Pier

Page 3: 5 Steps to Mastering the Art of Seaside
Page 4: 5 Steps to Mastering the Art of Seaside

Web ApplicationFramework

Page 5: 5 Steps to Mastering the Art of Seaside

MIT License

Page 6: 5 Steps to Mastering the Art of Seaside

Seaside is different by design

Page 7: 5 Steps to Mastering the Art of Seaside

We share as much state as possible

Page 8: 5 Steps to Mastering the Art of Seaside

We don’t use meaningful URLs

Page 9: 5 Steps to Mastering the Art of Seaside

We don’t use templates

Page 10: 5 Steps to Mastering the Art of Seaside

Seaside Applications are written in Smalltalk

Page 11: 5 Steps to Mastering the Art of Seaside
Page 12: 5 Steps to Mastering the Art of Seaside

5 Steps to Mastering

The Art of Seaside

Page 13: 5 Steps to Mastering the Art of Seaside

Agenda

Getting Started — 15 min

Components — 15 min

Callbacks — 15 min

Control Flow — 15 min

Outlook — 15 min

Page 14: 5 Steps to Mastering the Art of Seaside

1Getting Started

Page 15: 5 Steps to Mastering the Art of Seaside

Demo}VM

} Squeak, Seaside, Application(Platform Independent)

Page 16: 5 Steps to Mastering the Art of Seaside

Demo

Page 17: 5 Steps to Mastering the Art of Seaside

DemoClasses Methods

Source Code

Save & Compile(Command+S)

Page 18: 5 Steps to Mastering the Art of Seaside

Smalltalk

Everything is an object

Single inheritance

Method invokation is late bound

Methods are public

Instance variables are private

Page 19: 5 Steps to Mastering the Art of Seaside

Syntactic Elements

Comment "a lovely comment"Character $aString 'a nice string'Symbol #somethingInteger 123Float 2.718Array #( 1 2 3 )Receiver self

superBoolean true

falseUndefined nil

Page 20: 5 Steps to Mastering the Art of Seaside

Syntax (I)

Temporary Variable | var |Assignment var := aNumberBlock Closures [ stmts ... ]

[ :arg1 | stmts ... ][ :arg1 :arg2 | stmts ... ]

1. Unary message receiver doThis2. Binary message receiver + arg3. Keyword message receiver doThis: arg

receiver doThis: 2 andThat: 1

Page 21: 5 Steps to Mastering the Art of Seaside

Syntax (II)

Cascade receiver doThis: 123; doThatStatement stmt1. stmt2

stmt1. stmt2. stmt3Return ^ stmtParenthesis (stmt)

Page 22: 5 Steps to Mastering the Art of Seaside

Demo

Page 23: 5 Steps to Mastering the Art of Seaside

1Your Turn

Page 24: 5 Steps to Mastering the Art of Seaside

2Components

Page 25: 5 Steps to Mastering the Art of Seaside

We don’t think in pages ...

Page 26: 5 Steps to Mastering the Art of Seaside

..., but in stateful components

Page 27: 5 Steps to Mastering the Art of Seaside

Demo

Page 28: 5 Steps to Mastering the Art of Seaside

Demo

Page 29: 5 Steps to Mastering the Art of Seaside

Widgets

Page 30: 5 Steps to Mastering the Art of Seaside

View + Controller

Page 31: 5 Steps to Mastering the Art of Seaside

Persistent

Page 32: 5 Steps to Mastering the Art of Seaside

WAComponent

HelloWorld

Page 33: 5 Steps to Mastering the Art of Seaside

Canvas and Brush

Sou

rce:

sto

ck.x

chn

g, M

aart

en U

ilenb

roek

Page 34: 5 Steps to Mastering the Art of Seaside

CSSDesigner

Page 35: 5 Steps to Mastering the Art of Seaside

XHTMLDeveloper & Seaside

Page 36: 5 Steps to Mastering the Art of Seaside

DSL

Page 37: 5 Steps to Mastering the Art of Seaside

HelloWorld

renderContentOn: html

html render: 'Hello World'

Page 38: 5 Steps to Mastering the Art of Seaside

html div id: ‘title’; with: ‘Title’

<div id=”title”>Title</div>

Page 39: 5 Steps to Mastering the Art of Seaside

html div id: ‘list’; with: [ html span class: ‘item’; with: ‘Item 1’. html span class: ‘item’; with: ‘Item 2’ ]

<div id=”list”> <span class=”item”>Item 1</span> <span class=”item”>Item 2</span></div>

Page 40: 5 Steps to Mastering the Art of Seaside

2Your Turn

Page 41: 5 Steps to Mastering the Art of Seaside

3Interaction

Page 42: 5 Steps to Mastering the Art of Seaside

No freaking request parsing

Page 43: 5 Steps to Mastering the Art of Seaside

Don’t ask me,I call you

Sou

rce:

sto

ck.x

chn

g, L

evi S

zeke

res

Page 44: 5 Steps to Mastering the Art of Seaside

Callbacks

Page 45: 5 Steps to Mastering the Art of Seaside

html anchor callback: [ self inform: ‘Hello World’ ]; with: ‘Show Message’

Page 46: 5 Steps to Mastering the Art of Seaside

html textInput value: name; callback: [ :value | name := value ]

Page 47: 5 Steps to Mastering the Art of Seaside

CallbacksAnchors

Form ElementsText FieldsText AreaRadio ButtonsCheck BoxesSelectable ListButtons

Page 48: 5 Steps to Mastering the Art of Seaside

3Your Turn

Page 49: 5 Steps to Mastering the Art of Seaside

4Control Flow

Page 50: 5 Steps to Mastering the Art of Seaside

Demo

Page 51: 5 Steps to Mastering the Art of Seaside

<form action="result.html"> <input type="hidden" name="value1" value="<% value1 %>"> <input type="text" name="value2"> <input type="submit" value="OK"></form>

<p> <% value1 + value2 %></p>

<form action="second.html"> <input type="text" name="value1"> <input type="submit" value="OK"></form>

<form action="result.html"> <input type="text" name="value2"> <input type="submit" value="OK"></form>

Page 52: 5 Steps to Mastering the Art of Seaside

valu

e1, v

alue

2

/resultparsing

processingformatting

resu

lt

valu

e1

/secondparsing

processingformatting

valu

e1

/firstparsing

processingformatting

Web Browser

Page 53: 5 Steps to Mastering the Art of Seaside

Who cares about HTTP anyway?

Page 54: 5 Steps to Mastering the Art of Seaside

Seaside is different

Page 55: 5 Steps to Mastering the Art of Seaside

| value1 value2 |value1 := self request: ‘First Number’.value2 := self request: ‘Second Number’.self inform: value1 asNumber + value2 asNumber.

Page 56: 5 Steps to Mastering the Art of Seaside

AB

call:A Bx :=

Page 57: 5 Steps to Mastering the Art of Seaside

AB

answer:B

Page 58: 5 Steps to Mastering the Art of Seaside

A

x :=

Page 59: 5 Steps to Mastering the Art of Seaside

4Your Turn

Page 60: 5 Steps to Mastering the Art of Seaside

5Outlook

Page 61: 5 Steps to Mastering the Art of Seaside

Web 2.0

Page 62: 5 Steps to Mastering the Art of Seaside

XHTML

Page 63: 5 Steps to Mastering the Art of Seaside

CSS

Page 64: 5 Steps to Mastering the Art of Seaside

RSS

Page 65: 5 Steps to Mastering the Art of Seaside

AJAX

Sou

rce:

Flic

kr, B

enja

min

Jac

kso

n

Page 67: 5 Steps to Mastering the Art of Seaside

Tight, but optional integration

Page 68: 5 Steps to Mastering the Art of Seaside

Feature completeand up-to-date

Page 69: 5 Steps to Mastering the Art of Seaside

Say it in Smalltalk

Page 70: 5 Steps to Mastering the Art of Seaside

Demo

Page 71: 5 Steps to Mastering the Art of Seaside

Comet

Sou

rce:

Flic

kr, p

srm

an's

Page 72: 5 Steps to Mastering the Art of Seaside

Server Push

Page 73: 5 Steps to Mastering the Art of Seaside

Demo

Page 74: 5 Steps to Mastering the Art of Seaside

Applications

Page 75: 5 Steps to Mastering the Art of Seaside

In productive usesince 2002

Page 77: 5 Steps to Mastering the Art of Seaside

Demo

Page 78: 5 Steps to Mastering the Art of Seaside

Demo

Page 79: 5 Steps to Mastering the Art of Seaside

Demo

Page 80: 5 Steps to Mastering the Art of Seaside

Demo

Page 81: 5 Steps to Mastering the Art of Seaside

Demohttp://www.seasidehosting.st

Page 82: 5 Steps to Mastering the Art of Seaside

Did you notice?

Page 83: 5 Steps to Mastering the Art of Seaside

Web applications

Page 84: 5 Steps to Mastering the Art of Seaside

No URL fiddling

Page 85: 5 Steps to Mastering the Art of Seaside

No request parsing

Page 86: 5 Steps to Mastering the Art of Seaside

Development toolsat your fingertips

Page 87: 5 Steps to Mastering the Art of Seaside

Control flow at ease