Ask HN: expanding on MVC with frameworks for declarative UI description?

https://news.ycombinator.com/item?id=1408969
by DenisM • 16 years ago
9 4 16 years ago

Having written a bunch of UI code for iPhone I am now tempted to design my own framework to factor out reusable parts. However, before I begin I would like to tap into collective wisdom of this community - surely someone has done similar work before and if so I would be glad to learn rather than reinvent.

Here's how I see the structure of a single "page" in an application, expanding on MVC:

1. The Model - a software component and backing storage which provide access to the data. The important thing here is that Model itself must represent data how it's structured in the user's head, not how it's really stored in e.g. a relational database.

2. The Model Schema - a declarative description of types, relationships, and arity of the data entities stored in the Model. Model Schema could be an XML file, for example.

3. Text (Copy), possibly localized. A simple key-value text file would likely suffice.

4. Layout description - list of UI controls and their design attributes (colors, fonts, margins, alignment, grouping/proximity etc). This also includes binding from controls to the Model Schema and to Copy. Layout description also can be a declarative description, such as an XML file.

To make this whole thing come alive I would need a layout engine that can take layout description, create UI controls, populate them with data according to bindings and place them on screen according to design attributes, taking content into account. The difficult part is handling arity.

If I can pull this off, I can see enormous benefit: a designer, a developer, and a copy writer could be iterating independently based on a single common document - the Model Schema - and seeing the complete animated result of their work as they make progress.

So what are the closest things to this that someone else has already done or tried to do?

Note that existing iPhone UIKit cannot do content-sensitive layout, all layout positioning is independent of content and so often looks poor with truncated text or large areas of whitespace - this deficiency and the countless hours spent aligning text on screen were the primary motivators behind my thinking.

Related Stories

Loading related stories...

Source preview

news.ycombinator.com