News for hackers. Stuff that matters.
Re:What web developers thought of in the noughties as being ... by DonHopkins on Friday May 16, 2014 @11:11AM (#7755883)
When I was living with David Levitt, who worked with Alan Kay at Atari Cambridge Research, I was snooping around his bookshelves and read through some of the fascinating notebooks, in which Alan Kay wrote about the idea of a two way mapping/projection between the model and the view.

It's always seemed to me that the "controller" was just extra baggage, because the view knew the most about drawing the model, and naturally would also know what it needed to reverse that projection back from user input through to manipulating the model. But right now we usually meticulously write the view drawing and mouse tracking code by hand, without a lot of help from the system. (That's something I consider a high art form, which I enjoy diong, so I'd probably be horrified and out of a job it it were too easy! ;)

I think Ben Shneiderman's term "direct manipulation" describes the style of user interface that Alan Kay was getting at -- or at least DM has to deal with a lot of the same problems: "continuous representation of objects of interest, and rapid, reversible, incremental actions and feedback" according to http://en.wikipedia.org/wiki/Direct_manipulation_interface ...

By that I mean DM user interface programming could benefit from some kind of automatic inverter, but usually it's just implemented in an ad-hoc manner, usually by input tracking code in the view.

I think the way Smalltalk and Self/Morphic use reflection to present editable user interfaces to objects is another example of a two-way mapping between projecting the view on the screen, and editing the model via user input. Booleans whose values you can toggle, numbers whose values you can drag up and down, color pickers and things like that are all fine and good, but for many properties it has to fall back to standard widgets that don't know much about the semantics of the data they're viewing or editing.

I had the opportunity to play around with Sk8 when I was at Kaleida. That certainly let you drill down, see and modify everything there was in the system, and it was totally prototype based! Plus it had cool looking windows with neat shapes, which I like! ;)

I'm curious about what Kay meant by "projection", and what successful examples there are of automatic bi-directional mapping, and powerful user composition. I take it that projection is the problem that you lose dimensions and have to hide information by flattening the structure out onto the screen (via a 3d projection or scaling or filtering or whatever infovis technique you're using), and there's no visible place to click or affordance to edit some every property of an object (or you have to build scaffolding in the form of clumsy indirect manipulation techniques like browsers, outliners and pop-up menus).

Re:What web developers thought of in the noughties as being ... by twistedpair on Friday May 16, 2014 @01:42PM (#7756717)
You might like MVP then. There is pure UI manipulation (V - the view) and then the actual logic behind marshaling the UI and backend calls (P - the presenter), and finally the model. If you're on mobile/table/desktop, the presentation logic (i.e. form validation, RPC) will be the same, but the actual view code (to fetch the form field values/clear/set them) will differ.

I started with this on some projects last year and find it simplifies a lot of things. To boot, you can now rather easily test your presentation logic with no UI dependence (it's all in the V).

With MVP all the persistence stuff is a whole different place, in the REST/RPC services on the server (services and repositories) but it has no coupling at all with the UI or MVP. Makes life a lot easier.

Re:What web developers thought of in the noughties as being ... by barrkel on Friday May 16, 2014 @11:59AM (#7756151)
I've thought of the projection (bi-direction mapping) in terms of bijective functions that might be used in a data binding language.

So, consider a textbox on screen and an integer attribute on a model.

A bijective function might be a pair of (intToString, stringToInt) functions; one is the getter that projects out of the model, the other is the setter that takes from the view and pokes into the model.

Next, start think about how to compose bijective functions. How might they be packaged into bundles that represent a sub-component view of an individual model amongst many. And what might the mapping from a collection model look like; consider detail views (as in master-details), with a source of "currency" you can map from collection to "current item", and so on.

Re:What web developers thought of in the noughties as being ... by DonHopkins on Friday May 16, 2014 @12:13PM (#7756215)
Some alternatives to MVC for user interface programming that I've used and love are constraints / data binding / events and delegates.

I worked on the internals of "Garnet", a constraint based user interface management system written in Common Lisp on X11 (Brad Meyers' research system developed in the 90's at CMU) -- http://www.cs.cmu.edu/afs/cs/project/garnet/www/papers.html -- and also on the internals and applications of "OpenLaszlo", an open source cross platform XML/JavaScript based web programming system that supports Flash and browser JavaScript/HTML. http://www.donhopkins.com/drupal/node/124

Here is an article I wrote about constraints in OpenLaszlo and Garnet: Constraints and Prototypes in Garnet and Laszlo http://www.donhopkins.com/drupal/node/69

Oliver Steele (one of the architects of OpenLaszlo, and a great Lisp programmer) describes how OpenLaszlo supports "instance first development" and "rethinking MVC": http://osteele.com/archives/2004/03/classes-and-prototypes http://osteele.com/archives/2003/08/rethinking-mvc

I've used OpenLaszlo a lot, and I will testify that the "instance first" technique that Oliver describes is great fun, works very well, and it's perfect for the kind of exploratory / productizing programming I like to do. (Like tacking against the wind, first exploring by creating instances, then refactoring into reusable building block classes, then exploring further with those...)

OpenLaszlo's declarative syntax, prototype based object system, xml data binding and constraints support that directly and make it easy.

OpenLaszlo's declarative syntax and compiler directly support instance first development (with a prototype based object system) and constraints (built on top of events and delegates -- the compiler parses the constraint expressions and automatically wires up dependences), in a way that is hard to express elegantly in less dynamic, reflective languages. (Of course it was straightforward for Garnet to do with Common Lisp macros!)