Pages, Screens, MVC and not getting it…

MVC Web

About two years ago my colleague Ian Davis and I were talking about different approaches to building web applications. I was advocating that we use ASP.Net; The framework it provides for nesting controls within controls (server control and user controls) is very powerful. I was describing it as a component-centric approach where we could build pages rapidly by plugging controls together.

Ian was describing a page-centric approach, and advocating XSLT (within PHP) as one of several possible solutions. He was suggesting that his approach was both simpler and that we could be more productive using it. Having spent two years working with ASP.Net I was not at all convinced.

Two years on and I think I finally get what he was saying. What can I say, I’m a slow learner. The difference in our opinions was based on two different underlying mental models.

The ASP.Net mental model is that of application software. It tries to bring the way we build windows software to the web. ASP.Net has much of the same feature set that we have if building a Windows Forms app; it’s no coincidence that the two models are now called Windows Forms and Web Forms. In this model we think about the forms, or screens, that we have to build and consider the data on which they act as secondary – a parameter to the screen to tell it which user, or expense claim or whatever to load for editing.

In this mental model we end up focussing on the verbs of the problem. We end up with pages called ‘edit.aspx’, ‘createFoo.aspx’ and ‘view.aspx’; where view is the in the verb form, not the noun. ASP.Net is not unique in this, the same model exists in JSP and many people use PHP this way – it’s not specific to any technology, it’s a style of thinking and writing.

Ian’s mental model is different. Ian’s mental model is that of the web. The term URL means Uniform _Resource_ Locator. It doesn’t say Uniform _Function_ Locator. A URL is meant to refer to a noun, not a verb. This may seem like an esoteric or pedantic distinction to be making, but it affects the way we think about the structure of our applications and changing the way we think about solving a problem is always interesting.

If we think about URLs as being only nouns, no verbs, then we end up with a URL for every important thing in our site. Those URLs can then be bookmarked and linked easily. We can change code behind the scenes without changing the URLs as the URLs refer to objects that don’t change rather than functions that do.

So if URLs refer to nouns, how do we build any kind of functionality? That’s tied up in something else that Ian was saying a long time ago – when he asked me “What’s the difference between a website and a web API?”. My mental model, building web applications the way we build windows apps, was leading me to consider the UI and the API as different things. Ian was seeing them as one and the same. When I was using URIs refer to verbs I found this hard to conceptualise, but thinking about URIs as nouns it becomes clearer – That’s what REST is all about. URIs are nouns and then the HTTP verbs give you your functionality.

That realisation and others from working on Linked Open Data means I now think they’re one and the same too.

At Talis we’ve done a few projects this way. Most notably our platform, but also Project Cenote some time ago and a few internal research projects more recently. The clearest of these so far is the product I’m working on right now to support reading lists (read course reserves in the US) in Higher Education. We’re currently in pilot with University of Plymouth, here’s one of their lists on Financial Accounting and Reporting. The app is built from the ground up as Linked Data and does all the usual content negotiation goodness. We still have work to do on putting in RDFa or micro-formats and cross references between the html and rdf views – so it’s not totally linked data yet.

What I’ve found is that this approach to building web apps beats anything else I’ve worked with (In roughly chronoligical order – Lotus Domino, Netscape Application Server, PHP3, Vignette StoryServer, ASP, PHP4, ASP.Net, JSP, PHP5).

The model is inherently object-oriented, with every object (at least those of meaning to the outside world) having a URI and every object responding to the standard HTTP verbs, GET, PUT, POST, DELETE. This is object-orientation at the level of the web, not at the level of a server-side language. That’s a very different thing to what JSP does, where internally the server-side code may be object-oriented, but the URIs refer to verbs, so look more procedural or perhaps functional.

It’s also inherently MVC, with GET requests asking for a view (GET should never cause a change on the server) and PUT, POST and DELETE being handled by controllers. With MVC though, we typically think of that as happening in lots of classes in a single container, like ASP.Net or Tomcat or something like that. This comes from two factors in my experience. Firstly the friction between RDBMS models and object models and secondly the relatively poor performance of most databases. These two things combine to drive people to draw the model into objects alongside the views and controllers.

The result of this is usually that it’s not clear how update behaviour should be divided between the model and the controllers and how display behaviour should be divided between the model and the views. As a result the whole thing becomes complex and confused. That doesn’t even start to take into account the need for some kind of persistence layer that handles the necessary translation between object model and storage.

We’ve not done that. We’ve left the model in a store, in this case a Talis Platform store, but it could be any triple store. That’s what the diagram at the top shows, the model staying seperate from views and controllers… and having no behaviour.

A simple example may help, how about tagging something within an application. We have the thing we’re tagging, which we’ll call http://example.com/resources/foo and the collection of tags attached to foo which we’ll call http://example.com/resources/foo/tags. A http GET asking for /resources/foo would be routed to some view code which reads the model and renders a page showing information about foo, and would show the tags too of course. It would also render a form for adding a tag which simply posts the new tag to /resources/foo/tags.

The POST gets routed to some controller logic which is responsible for updating the model.

The UI response to the POST is to show /resources/foo again, which will now have the additional tag. Most web development approaches would simply return the HTML in response to the POST, but we can keep the controller code completely seperate from the view code by responding to a successful POST with a 303 See Other with a location of /resources/foo which will then re-display with the new tag added.

“The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource.” rfc2616

This model is working extremely well for us in keeping the code short and very clear.

The way we route requests to code is through the use of a dispatcher, .htaccess in apache sends all requests (except those for which a file exists) to a dispatcher which uses a set of patterns to match the URI to a view or controller depending on the request being a GET or POST.

Ian has started formalising this approach into a framework he’s called Paget.

Passion, personal brand, and doing what you love…

Just found this great video of Gary Vaynerchuk keynoting at Web 2.0 Expo in New York. I found it via the Natural User Interface blog.

Vaynerchuk’s keynote is entitled “Building Personal Brand Within the Social Media Landscape” but the main thrust of it is that everyone should stop doing what they hate and do something they really love.

The timing of this is interesting as I’ve recently had a few conversations with folks at work about loving, or not, what they’re doing. At Talis it can be hard to find what it is you really want to do; we expect people to self-organize and have a high degree of self-awareness.

When I worked at Egg, we found very strongly that people joining the company either loved it and thrived or hated it and didn’t. This came down to one thing – was what Egg was doing something you were passionate about.

We’ve come round to a similar culture at Talis, one where we’re all actively encouraged to find out what it is that we love doing and supported in getting into that role. Of course, we’re not in just any business so if I decided I wanted to become a goat farmer then Talis and I would have to part company.

Knowing what it is that you love doing, and often that’s based on discovering and understanding your strengths, is crucial to understanding if an organizational culture is right for you and even if the organization’s business ambitions are right for you.

Having worked in companies that I’ve loved and in companies I loathed and in roles of both kinds within both kinds of company I’m starting to get clear on what I love doing. Right now my role involves bringing together really cool ideas like Linked Data and great interaction design with existing problems in higher education. We’re building lightweight stuff quickly and easily to test out ideas and constantly looking for the very essence of solutions. And more importantly than all of that, I’m working with people who are smarter than me and who inpsire me with great ideas.

That’s what I love, but the very same culture can be experienced by others very differently.

Right now I’ve found something pretty close to what I love doing – you should do that too :-)

Microsoft Love/Hate

I’m often accused at work of being somewhat of a Microsoft hater. It’s often fun, and easier, just to go along with it. The only difficulty with that is… it’s simply not true.

A few years ago I was working at Egg and was one of the key proponents of introducing ASP.Net and C#. At the time the existing infrastructure for the main customer site was also one I’d been involved in choosing – Netscape Application Server (NAS), a Java based app server and Vignette StoryServer, a TCL/TK based content management server. After just 3 years of service both were looking under-loved by their respective vendors.

Microsoft had been knocking on Egg’s door for a long time, and with ASP.Net they presented a very interesting offering. Not only that, but by taking steps to work with ASP.Net we opened doors into Microsoft to get early demos of Longhorn – this is before the re-write, at a time when it was exciting and had far more innovation than was left by the time it shipped.

I even ended up (incorrectly quoted) in a case-study for Visual Studio and .Net. Microsoft even sent a small film crew and interviewer to make a short video on Egg’s use of Visual Studio with us. Of course, the meat of the discussion was edited out, so it looks like all I said was "Visual Studio is Fantastic".

So why am I writing this now? Well, the rather brilliant Elliott has decided to learn C#, but seems a little defensive about the decision. I just wanted to encourage him to go for it. C# is a very nicely designed language and the .Net framework is a comprehensive, elegant collection of things that makes doing almost anything easier.

At Talis we built some stuff using ASP.Net too, and it was good.

We’re not using it now mostly because of cost. We can run much more cheaply for the kind of applications we’re building using open-source products. The application we’re currently piloting is written in PHP5, running in Apache on CentOS. Free, in every sense of that word. The only thing we pay for is an account on the Talis Platform, which handles all of our data storage needs. This keeps costs down and means we can sell the product for less (it’s SaaS).

Is PHP as nice to write as C#? I don’t think so, but then C# is not as nice to write as Ruby. Is PHP as fast as ASP.Net? I don’t think so, although the way we write our apps usually has a bigger impact than the language. Is PHP the right tool for this job? Definitely.

Is C# still worth learning? Definitely.

Asshole.

No, not you. At least I hope not.

Like Robert Sutton, I am a self-confessed asshole. That is, from time to time, I have the potential to act like an asshole to the people around me.

Also like Robert Sutton I neither want to be considered an asshole nor do I want to work with people I consider to be assholes. So when I read (some time ago) that Bob Sutton had walked away from a publishing deal with Harvard Business School Press because they wouldn’t let him use the word ‘asshole’ in his title I thought "assholes".

It’s taken the best part of eighteen months for The No Asshole Rule to filter to the top of the pile of books next to my bed, so last week I finally read it. I should have read it eighteen months ago, when I found it :-(

The book covers a great amount of research into asshole statistics as well as anecdotal stories of assholedom. Sutton gives simple, highly loaded, tests to self-assess your own asshole score (I scored only moderately) and describes techniques to help you survive asshole encounters. The thrust throughout all the chapters of the book, though, is that nobody should have to put up with assholes, not at home, not at work, not anywhere. And I agree.

He quotes a good few people, Lars Dalgaard CEO of SuccessFactors amongst them:

respect for the individual, no assholes – it’s okay to have one, just don’t be one … because … assholes stifle performance

Sutton even includes a chapter on the virtues of being an asshole, albeit with a significant bias as he shows that the virtues are perceived rather than actual. He wraps that chapter up with:

[life is] too short and too precious to spend our days surrounded by jerks. And despite my failures in this regard, I feel obligated to avoid inflicting my inner jerk on others. I wonder why so many assholes completely miss the fact that all we have on this earth are the days of our lives … We all die in the end, and despite whatever ‘rational’ virtues assholes may enjoy, I prefer to avoid spending my days working with mean-spirited jerks and will continue to question why so many of us tolerate, justify, and glorify so much demeaning behaviour from so many people.

Now that’s a sentiment I can get behind.

Fortunately, working at Talis, we have a very good culture overall. People are supportive of each other and enjoy sharing knowledge, learning and getting better at what we do, together. In particular we have people in leadership positions who are (almost) never jerks let alone assholes. And that’s a great example to set.

So, to all those who have tolerated me when I have not kept my inner-jerk under control, thank you.

Read Write Wrangle with Talis

Read/Write Web have been digging into us in a bit more detail.

The piece is a pretty good overview and it’s great to see how much they’ve understood about us and the culture we’re trying to build and maintain.

Project Cenote, a concept car Nad and I built some time ago gets a mention, described as having an “aesthetically pleasing interface” – with hindsight I think there just maybe a bit too much chrome going on ;-)

The author, Zach Beauvais, seems to be finding the idea that we are two things difficult. He’s not the first. We’re both a vertical software provider in the library market in the UK and a horizontal platform provider for anyone who want to play with Semantic Web data anywhere in the world. We have some of the best people in both of those arenas working for us – which actually makes it very easy to balance those two aspects internally.

It’s incredibly pleasing to see this kind of review of us – it feels spot on, we try to be open and relaxed and do the very best we can. Hopefully we’ll see more of this kind of coverage as more people get to know us.

Open Data Commons License

At work we’ve just announced some great news. The Open Data Commons license is out – in collaboration with Creative Commons and others.

The new home for the license is at http://www.opendatacommons.org/ and the new licenses are available there for comment.

The only downside is that the full name of the license ended up as the Open Data Commons Public Domain Dedication and Licence ODC PDDL which will inevitably end up being called the pee-diddle.

How long to change culture

Over on Tiny Drops of Knowledge (the name belies the depth of the content) Lyndsay posted about changing culture – in his case being part of a team moving from VB to C#.

At Talis we find we’re constantly changing, and have been for longer than my three years here. At Talis that change has been about talent, responsibility, empowerment, achievement, learning, fun and real values.

Lyndsay says:

A reoccurring challenge we’ve faced on this project is re-learning how to write software. Its more than just learning a new language, tool or framework, its more like loosing the shackles of apartheid.

Over the past few years I’ve concluded that this is the normal state of affairs. When I first started work I was given some great advice – my boss told me, when I handed my notice in, to make sure that wherever I went I wasn’t the smartest person there. What he was getting at is the need in me, and many of the people I count as my closest friends, to be constantly finding out new things. I thought nothing more of it at the time.

But then, working with folks at Talis I realised the very real truth that “the more I learn the less I know”. And I’m okay with that. Not everyone is, but I think it’s key to being as productive as you can be. The change Lyndsay is talking about may be the change from writing instructions for the computer to modeling a problem for yourself and your colleagues. Once you’ve made that leap it makes sense to understand as many different ways of modeling problems as you can – at work we’ve been through OO design in Java through procedural code in PHP and functional code in XSLT to discussions of the similarities between Prolog and how we initially perceive how we might work with RDF.

There’ll be something else tomorrow. I know there will because I work with a load of people who are smarter than I am.

Technorati Tags: ,