29
1 Monorail Monorail Complex Complex Lifecycle Lifecycle MVC MVC SoC SoC IoC IoC integratio integratio n n Unneeded Unneeded Abstracti Abstracti on on HTTP HTTP

Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

Embed Size (px)

Citation preview

Page 1: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

1MonorailMonorail

ComplexComplexLifecycleLifecycle

MVCMVC

SoCSoC

IoC IoC integrationintegration

Unneeded Unneeded Abstraction Abstraction

HTTPHTTP

Page 2: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

2About MeAbout Me

Ken Egozi

BASIC > C > Turbo Pascal > VB > WebForms > RoR >

Monorail

Blogs at http://www.kenegozi.com/blog/

Have created AspView, the C# View Engine for Monorail

Participates in Open Source projects, mainly Castle Project

Page 3: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

3

FindControl(“tblData”).Rows[3].Cells[2].Text = …

int age;var succeed = int.TryParse(txtAge.text, out age);

Page 4: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

4The web is simpleThe web is simple

URLs have meaning – R for *Resource*

/item?id=32refers to the item with id=32

/items?category=boots&page=2refers to the second page of items, which belongs to ‘boots’ category

/boots/items/2, /item/32 same things

Page 5: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

5The web is simpleThe web is simple

Request parameters:

Within the URL (http://server/path?query)

Within the request body

The format for request parameters is:name1=value1 & name2=value2

Arrays can be passed using

name=value1 & name=value2 …

Page 6: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

6The web is simpleThe web is simple

Common types of requests (http verbs)

GET Retrieve data from a server. The data is identified by URL.

POST Sending data to a server for storage or processing

Page 7: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

7The web is simpleThe web is simple

Common response codes2xx Success

200 (OK), 201 (Created)

3xx Redirects301 (Moved), 307 (Temporarily redirected)

4xx Errors404 (Not found)

5xx Server errors500 (General error), 503 (Unavailable)

Page 8: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

8

Page 9: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

9Monorail is a …Monorail is a …

MVC Web FrameworkOpen source, with a thriving community

○ Built by the framework users

Built on top of ASP.NET

○ Caching

○ Session Management

○ Authorisation

○ Authentication

○ Http Modules

○ etc.

Mature, running many websites all around

Page 10: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

10Core Principles:Core Principles:

Simple

Maintainable

Convention over Configuration

Less code(as in: Less code, not as in: *.generated.cs)

Testable, TDD friendly

Page 11: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

11

Page 12: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

12Monorail LinguaMonorail Lingua

Action corresponds to a group of resources (vary by

query/form)In code: a plain old .NET method

ControllerA logical group of actions

In code: a .NET class which implements IController

public void Login(string username, string password){}

public class UsersController : SmartDispatcherController{}

Page 13: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

13Monorail LinguaMonorail Lingua

ViewA template for rendering markup to be sent to the client.

LayoutA view that acts as a container for the rendered view

Page 14: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

14Monorail LinguaMonorail Lingua

Sub ViewA view that will be rendered within another view.

View ComponentA component that can encapsulate presentational logic

and view processing. Can have several views associated with it

Page 15: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

15SimpleSimple

“Hard work” Business decisions

DB accessWeb Service

Controller

String manipulations

View

Common logic

Filter

Common logic

Filter

Page’scode-behind

Page’sMarkup

Control’scode-behind

Control’sMarkup

WebFormsMonoRail

Page 16: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

16MVCMVC

View Controller Model

GETLoad()

RenderHTTP

POSTUpdate()

Redirect

Load()

RenderHTTP

Sequence

Page 17: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

17ConventionsConventions

URL Action

http://www.my-cool-domain.com/post/show.aspx?id=2

Nothing new Controller

Action

Aspnet_isapi.dll

Nothing new

Page 18: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

18ConventionsConventions

URL Action

http://www.my-cool-domain.com/post/show.aspx?id=2

Page 19: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

19

Page 20: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

20Monorail vs. WebformsMonorail vs. Webforms

ImpossibleEasyView testing

hacks/SOAP/.ashxSimple, REST likeAPI

Single huge form, viewstate, POST

All aspect (VERBS, Multiple forms)

HTTP/HTML

__VIEWSTATE field in the form

Easily (OSS), Conventions

Extensible

ComplexSimple Lifecycle

Everything is .TextValues, ClassesDatabinding

Can be addedBaked in,Simple conventions

MVC

WebFormsMonorail

Page 21: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

21FUDFUD

Cannot Use Third-Party CustomControls?It’s easier to squeeze the designer’s markup into a

foreach/if-else than into an OnItemDataBoundCan use Third-Party DHTML/JS client libraries

How Do I Hire Developers?Decent WebForms developers should grasp the

principles quicklyYou actually gain access to seasoned PHP/RoR/ASP/

developersThere’s a learning curve anyway

Page 22: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

22View EnginesView Engines

Official view engines:BrailAspView NVelocity

Contributed view engines:XsltStringTemplateNHaml

Page 23: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

23Project StatusProject Status

Version 1.0 is nearly out of the door

What’s missing?

Docs,

Samples,

Better Visual Studio integration

Can you help with that?

Page 24: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

24How To Get MonorailHow To Get Monorail

Castle Official ReleasesPro:

○ Official○ Documentation○ Stable○ Wizards

Cons:○ Not cutting edge

A new release will be available in the near future

Page 25: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

25How To Get MonorailHow To Get Monorail

Build ServerPro:

○ Stable enough○ Cutting edge

Cons:○ No wizards○ Compilation target: Debug

Page 26: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

26How To Get MonorailHow To Get Monorail

Build Yourself

Pro:

○ Cutting edge

○ Build options (Release? 1.1? Mono? Medium-Trust?)

○ Apache license => can be tailored

○ Patches get applied => worldwide professional recognition

Cons:

○ Need tools (Subversion, NAnt)

○ Must find a stable revision

Page 27: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

27Monorail vs. ASP.NET MVCMonorail vs. ASP.NET MVC

Both are great, and better than Webforms

ASP.NET MVC’s major pros:Larger user communityOfficial support ?

Monorail’s major pros:MatureBuilt by the framework usersOpen source with permissive licenseWAY cooler …

Page 28: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

28LinksLinks

Website: http://www.castleproject.org

Mailing list:[email protected]

Wiki:http://using.castleproject.org/display/CASTLE/Home

Page 29: Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

29LinksLinks

Blogs:

http://hammett.castleproject.org

http://ayende.com/Blog

http://www.kenegozi.com/blog

http://benl.wordpress.com

http://devlicio.us/blogs/mike_nichols

http://andypike.wordpress.com

http://jonorossi.com/blog