Monorail presentation at WebDevelopersCommunity, Feb 1, 2009

Preview:

Citation preview

1MonorailMonorail

ComplexComplexLifecycleLifecycle

MVCMVC

SoCSoC

IoC IoC integrationintegration

Unneeded Unneeded Abstraction Abstraction

HTTPHTTP

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

3

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

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

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

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 …

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

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)

8

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

10Core Principles:Core Principles:

Simple

Maintainable

Convention over Configuration

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

Testable, TDD friendly

11

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{}

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

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

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

16MVCMVC

View Controller Model

GETLoad()

RenderHTTP

POSTUpdate()

Redirect

Load()

RenderHTTP

Sequence

17ConventionsConventions

URL Action

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

Nothing new Controller

Action

Aspnet_isapi.dll

Nothing new

18ConventionsConventions

URL Action

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

19

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

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

22View EnginesView Engines

Official view engines:BrailAspView NVelocity

Contributed view engines:XsltStringTemplateNHaml

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?

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

25How To Get MonorailHow To Get Monorail

Build ServerPro:

○ Stable enough○ Cutting edge

Cons:○ No wizards○ Compilation target: Debug

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

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 …

28LinksLinks

Website: http://www.castleproject.org

Mailing list:castle-project-users@googlegroups.com

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

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