iHack, therefore iBlog

September 26, 2011

RIBS: Marrying the REST and MVC Design Patterns

Filed under: REST,Software — Dr. Ernie @ 2:33 pm

[Diagram updated on 10/27. Thanks to @frozencanuck for his feedback.]

The RIBS diagram is my third attempt to extend the wildly-succesful Model–View–Controller design pattern to encompass first the The DCI Architecture and now the REST architectural style.  This time, I started by reverse-engineered the design principles behind the Ki Statechart Framework, particularly their use of statecharts as coordinating controllers.

I also have a clearer picture of what I am doing:  trying to identify a general design pattern for computational systems.

Here’s what it looks like so far:

Resource • Interface • Behavior • State

  1. The purpose of a System is to manage a Resource
  2. A System contains a Resource, one or more States and their Behaviors, an Interface for each State, plus relationships with zero or more Peers.
  3. An Interface (which could also be a System of its own) consists of active Actions and passive Presentations available to an external Client.
  4. When a Client invokes an Action, the System routes it to the appropriate Behavior for the current State (the routing is necessary if there are multiple concurrent states, otherwise it can be elided).
  5. A Behavior can in general a) adapt a Resource, b) interact with a Peer, and  c) initiate additional Behavior
  6. Resources present to an Interface and adapt to a Behavior
Importantly, this is a conceptual document, not a software architecture.  To be sure, it is intended to map easily onto traditional MVC objects:
  • Views are Interfaces
  • Models are Resources that can adapt and present themselves
  • Controllers manage State, routing, and connections with Peers
This implies that traditional MVC concepts are actually aggregates of other, more primitive concepts.  Indeed, advanced programmers often add presenters, adapters, routers, state machines, and behavioral strategies in order to overcome the brittleness of pure MVC.
However, the RIBS pattern is actually more general than that, because it applies even below the object level:
  • Views can be systems, whose Resource is a drawing context and Behavior is hit detection
  • A Model object could itself be a system, with a database row as its Resource and business logic as its Behavior
You might say that one system’s Interface is another system’s Resource.  In fact, RIBS can also be used at a much higher level to describe RESTful web services:
  • Hypertext is an Interface  (HTML) which uses Routes (URLs) to embed State
  • Behavior is driven by a small set of Actions (HTTP verbs) against a specific Resource
In short, a RESTful system pulls the State into the Interface enabling you to work directly with Resources.
At least, thats the theory, as best I currently understand it and can articulate it. What do you think? Can you do better?

September 16, 2011

SIDA: Moving Object-Oriented Design beyond Model-View-Controller

Filed under: Software — Dr. Ernie @ 2:18 pm
Tags: , ,

[Update: this post has been obsoleted by RIBS: Marrying the REST and MVC Design Patterns « iHack, therefore iBlog]

SIDA stands for “State • Interface • Data • Algorithm“, and is a refinement of my earlier “DIDA” model (where the “D” stood for Design).  DIDA in turn was an expansion of the well-known Model–View–Controller design pattern based on insights from the Data-Context-Interactions architecture.

State • Interface • Data • AlgorithmThe key premise of SIDA is that there are four primary artifacts that need to be designed, from the most important on down:

  1. Concrete States
  2. Clear Interfaces
  3. Consistent Data
  4. Concise Algorithms
These in turn are related in a particular system via the:
  1. Presentation of Views
  2. Controlling of Actions
  3. Binding of Roles

as shown in the accompanying diagram.

In a simple system, the state is implicit and the relations are absorbed into one of the artifacts, reducing SIDA to the traditional View, Model, and Controller, respectively.  For more complex systems, however, it may make sense to design explicit objects for each relation, e.g., traits for roles, presenters for views, and strategies for actions.

In addition, SIDA is intended as a general architecture, describing the internal structure of everything from databases to web services to GUI applications.  An interface as defined from inside the system may appear as data or an algorithm from outside the system.

The most interesting (and perhaps unusual) aspect of this diagram is how it makes state a central features, something developers never use. If state really is so central to the design process, perhaps it deserves explicit language support, as provided by UnrealScript or typestates (as in Rust).

This is all still merely a hypothesis on my part, as I haven’t actually put any of this into practice yet.  Anyone with more experience care to comment?

September 15, 2011

DIDA: Reinterpreting MVC object modelling in light of DCI

Filed under: Software — Dr. Ernie @ 12:36 pm
Tags: ,

[UPDATE: This post has been obsoleted by SIDA: Moving Object-Oriented Design beyond Model-View-Controller]

I recently read about The DCI Architecture: A New Vision of Object-Oriented Programming, a successor/complement to the original Model–View–Controller design pattern, by one of the original authors.  The DCI stand for:

  • Data
  • Context
  • Interaction
I was both impressed and confused.  Impressed because I’ve been thinking for a while that MVC wasn’t quite sufficient, and this seems like a big leap forward.  Confused, because most of their discussion revolved around roles (typically implemented as traits) and algorithms, so I couldn’t quite figure out where exactly Context and Interactions fit in — much less how they related to MVC objects.
Design Interface Data AlgorithmTo help me sort it all out in my head, I developed a comprehensive picture I call DIDA, which attempts to incorporate both MVC and DCI in a single unified design pattern. DIDA stands for:
  • Design
  • Interface
  • Data
  • Algorithms
In a sense, it uses the critique from DCI to tease apart to the components of MVC.   In particular, traditional MVC tends to combine the roles and data into model classes, the presentation and interface into a view hierarchy, and all the actions and algorithms into a single controller.  The key insight of DCI (as best I understand it) is that  roles should be kept distinct from the “mostly dumb” data, and only bound in the context of a particular algorithm, which should be clearly spelled out in its own software construct. I used the same logic to similarly extract the Presenter Pattern from views and to separate controllers from algorithms.
The basic idea is that the Interface, Data and Algorithms are three primary nouns you need to Design as part of an application (roughly in that order).  Those in turn determine the roles, presentation, and actions necessary to wire everything together.  Depending on the use cases, it may make sense to implement everything as traditional MVC objects, but it might be wiser to use, e.g., traits, presenters, and strategies to enable weaker coupling.
As far as I can tell, this approach captures the key benefits of DCI, but is much easier to understand and apply. Of course, I could easily be overlooking something. Please let me know what you think.

January 2, 2011

2010 in review

Filed under: Admin — Dr. Ernie @ 7:53 am

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Fresher than ever.

Crunchy numbers

Featured image

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 9,700 times in 2010. That’s about 23 full 747s.

In 2010, there were 4 new posts, growing the total archive of this blog to 90 posts. There were 6 pictures uploaded, taking up a total of 282kb.

The busiest day of the year was April 1st with 158 views. The most popular post that day was Bonjour-enabled iPhone Remote.app wins rave reviews.

Where did they come from?

The top referring sites in 2010 were myphone.gr, sethgodin.typepad.com, twitter.com, facebook.com, and linkedin.com.

Some visitors came searching, mostly for ihack, ihack.us, rjs tutorial, bonjour iphone app, and ihack iphone.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

Bonjour-enabled iPhone Remote.app wins rave reviews July 2008

2

Great JavaScript-in-Ruby (RJS) Tutorial: What I Learned June 2006

3

Building a GUI for MacPorts March 2008
4 comments

4

Migrating from Steel.app to 1Password August 2009
1 comment

5

Using tel: Telephone URLs in iCal Events March 2010

July 1, 2010

What Makes Programming Languages Successful?

Filed under: Software — Dr. Ernie @ 2:21 pm

Following up on my (subjective) list of what I like about Ruby, here’s a (relatively objective) list based on articles about what makes programming languages successful. (more…)

Teach Me Time! Talking Alarm Clock & Nightlight (review)

Filed under: Fun and Games — Dr. Ernie @ 11:50 am

Worked wonders for our 26-month old

June 29, 2010

What I love most about Ruby

Filed under: Software — Dr. Ernie @ 11:06 am

I have some friends (Hi Dustin) that are serious language geeks, whom I often get into debates with. One of my common refrains is “to do it the Ruby way”, because (while Ruby has its warts) it does so many little things beautifully well. So, as future ammunition, I figured I should try to collect links to my favorite Ruby features (much as many others have already done before me).

(more…)

March 5, 2010

Using tel: Telephone URLs in iCal Events

Filed under: X[HT]ML — Dr. Ernie @ 2:17 pm

Mac iCal telephone URLs

iPhone iCal telephone URLs

[NOTE: I'm still trying to figure this out, but here is my current best understanding; please leave a comment if you have additional information].

A useful trick not many people know is that you can embed a telephone URL in an iCal entry, to make it easy for people attending to call-in.  This is especially useful for when the meeting itself is a Conference Call and people are dialing in on their iPhones.

(more…)

November 24, 2009

Intrigued by Posterous

Filed under: Admin — Dr. Ernie @ 2:26 pm

http://drernie.posterous.com/

Yes, I know I’m late to the party. But, now that they have Twitter and LinkedIn support, I figured I should take the plunge. This may be particularly useful for increasing the number of updates on http://ihack.us/. If so, I guess you’ll see about it here. :-)

November 10, 2009

Active Identity Clients (AICs) for OpenID

Filed under: Identity — Dr. Ernie @ 5:18 pm
Tags: , ,

“Enough is enough! I have had it with these #@%!*$ AICs and their #@%!*$ panes” — Samuel H.S. “Hammer Stack” Jackson (with apologies to Neville Flynn)

Introduction

The OpenID community is still wrestling with how to deliver a first-time login experience that is acceptable to mainstream users. Research indicates we need something less open-ended than typing into a blank URL field, but neither is it desirable to push users to choose from a few (or worse, many) pre-selected identity provider logos.

One approach for solving this problem is called (for lack of a better term) the Active Identity Client, or AIC (similar to what I previously called a Chamberlain). An AIC boostraps the identity selection process at a new website (aka Relying Party, or RP) by storing some amount of identity information on the user’s home computer. The AIC uses that identity to access a persistent record of the user’s interaction with multiple sites and identity providers (IdPs) to negotiate and streamline future such interactions. This (in theory) allows the user, rather than the RP, to prioritize which providers to use.

A number of such AICs were demonstrated at last week’s Internet Identity Workshop. Rather than attempting to standardize on a single AIC, a group of us discussed developing a common infrastructure that might enable a broad spectrum of AICs to innovate and compete. Specifically, we attempted to identity conventions, best practices, and extensions to existing standards that would support both “native” and “in-browser” AICs.

This article is my idiosyncratic attempt to synthesize what we discussed into a coherent vision for Active Identity Clients. It may not fully reflect the opinions of any given participant, and certainly does not represent the views of our respective employers. Rather, it is a subjective snapshot of a still-evolving problem space, and is intended to provide a concrete starting point for further discussion, critique, and clarification. (more…)

Next Page »

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.