Coding Inside-in and Outside-out

1 AM December 22, 2003

My latest assignment, a terminal based, C++ application, is a pleasant change from the web based, Java applications that I had been working on for the last year. Even with Java’s advantages over C++, I suspect it would take longer to build a web version of this application than a terminal version.

A typical web application consists of a bunch of little programs, all doing this:

  1. Work out what the user wants to do.
  2. Work out if the user’s session is in the correct state to do that.
  3. Validate the input.
  4. Peform the action.
  5. Save session state so you know where you are for the next request.
  6. Generate the HTML response.
  7. Return to the server.

Early on, the Java people standardised the interface to these little programs and called them servlets.

In constrast, a terminal application has a bunch of subroutines that all look like this:

  1. Display a screen.
  2. Get an action from the user.
  3. Perform the action.

Not nearly as complex. And because the code is not stopping and starting with each interaction, there are no session state bugs, fewer security issues, and it really is about half the code.

Aaron Watters puts it succinctly:

Unrolling the application at each point where you need to wait simply turns the code inside out…

Of course, the reason why we write our applications inside-out is that it scales much better than if we don’t. What if there was a way to build scalable applications “inside-in and outside-out”? Jeremy Hylton points to a number of papers and projects addressing this problem.

By alang | # | Comments (2)
(Posted to javablogs, Software Development and Java)

Comments

At 21:33, 23 Dec 2003 Nicola Ken Barozzi wrote:

@see http://cocoon.apache.org/

The latest version supports serverside continuations and works exactly like a programmer would expect.

The nice thing is that it also has pipeline model that makes it easy to declare what to do with the xml, and that is easily accessed by the flowscript.

(#)
At 01:51, 24 Dec 2003 F.Baube wrote:

Another project with continuations is RIFE

https://rife.dev.java.net/

I've been using it and found it highly intuitive.

HTH!

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green