UI Mappers: A Common Scenario

The best way to understand what I mean by a UI Mapper is to look at a common scenario -- let's say you have to add a new business entity to your new or existing application.  What do you have to do to support this new entity?  Data, business logic, and UI screens.  If you use an O/R Mapper then you will only need to create your mappings for the data, otherwise you will need to create your sql or stored procs, and hook it all to your DAL.  As for business logic, some people "skip" this and use datasets, but lets get to the UI.

You'll almost always need to provide a list/grid to view all of your entity instances, as well as provide a screen to create a new instance and to edit any existing instance.  A basic list is easy in ASP.NET -- just drop a grid and bind it to your entity/dataset.  But what happens when you want to not display some columns, or change the alignment or format of some columns, and how much code do you have to write for sorting and paging?  How easy is it to enforce a consistent layout across all of your various list screens, or is it possible to define the alignment and formatting of a column in just one place?  Do you have to create separate screens for different roles or locales that require yet another version of your list -- and do you even have the possibility for personalization?

That's beginning to not be so easy afterall, and that was just the simple list screen.  What about the edit screen -- it requires the designer to place lots of edit controls, add validator controls, load the data into the controls, and then save the user entries.  This may not be hard, but its very repetitive, and there is little to no reuse at all!  That's right -- its not easy at all to enforce a consistent layout across edit screens, and any reuse of an edit control with specific properties requires a whole user control.  And what about a read-only view, or a different view for specific roles or locales again?  None of this is really very "hard", but its very repetitive in even the simplest of cases, and it can become a maintenance nightmare when you need personalization and localization.

A UI Mapper approach lets you simply define the meta-data for these list/edit screens.  Yes, you will lose the "control" over every minute detail of your layout you have now, but in most cases that total "control" is what makes it so hard to get any consistency.  Yes, ASP.NET v2.0 will make some of it easier, but most of the issues will still remain.  And we haven't even looked at the scenario where you need both Web and WinForm clients.  So what features does a UI Mapper need in order to make this something you would consider?

Published Monday, July 12, 2004 7:38 AM by PaulWilson

Comments

# re: UI Mappers: A Common Scenario

Hi Paul,

first of all, I like the idea especially if it will be executed in the same excellent way as your O/R mapper; and I have no doubt that you'll manage to do that. There are a couple of tools out there that produce the full cycle (mapping, interface, business logic), so the idea is not that new. While I dislike code generators for O/R mappers, I would prefer them for a U/I generator. The reason is that I don't want go deep inside the code of the DAL as for me the whole purpose of having such a tool in the first place is that I do not have to do that in the first place. With U/I mappers it is different. I see them more as starting points to get results quickly, but it is quite clear from the very beginning that I will need to do extensive changes. Why? - As with race cars, I will buy the engine (DAL) and build or tweak the chassis ;) - A couple of examples: sometimes I may need to use a certain special UI part such as WebGrid.NET or ComponentArt's treeview. I don't expect a U/I helper tool to know everything about all these tools, so I really need source code here in contrast to the DAL (where is it ok to have 'hooks' just in case you need to do something special). So, the tool should supply simple pages as you suggest, use a master page/template approach, concentrating on CSS, preferably work in conjunction with your O/R mapper and should produce source code, so that I can tweak it if I need to.

Best regards,

Marc

Monday, July 12, 2004 8:40 AM by Marc Hoeppner

# re: UI Mappers: A Common Scenario

I wnat to second marc's opinion.

I would love to see some work done in this area, but I do Nnot think it would be applicable. See, UI is design, and design needs to look good. And is something we will never be able automate. Most generated UI's look like some dumpass without a clue in design worked on it.

Personally I think a limited use set of objects along the line of "make it easier to make standard ui's", together with IDE integrated wizards (coming with Whidbey) are a better approach.

But I would be more than glad to see myself prooven wrong.

Monday, July 12, 2004 9:08 AM by Thomas Tomiczek

# re: UI Mappers: A Common Scenario

I totally agree that a UI code generator may be the way to go for many cases -- I think it depends on how much control you need (code generator) vs. how much flexibility you need (meta-data driven). I also don't think there are many applications where you can get away with ALL of your screens dynamically created off of meta-data, but I do think many (if not most) apps have a lot of boring admin-type screens that could be based on meta-data. I think those are usually easy to create with the typical UI controls, and I do want to have some type of hooks for custom controls also, although you're right it may never be able to incorporate all the advanced features of those, but will those really apply to the simple cases. Anyhow, I think UI code gen is better than manual tinkering in most cases, if you can't go the meta-data approach, so I hear you -- and I heartily recommend CodeSmith for code generation and have no intention of competing with it.

BTW, I doubt I'll ever prove Thomas wrong. :) But I do know that many have communicated with me wanting something along the lines of what I'm describing as a UI Mapper.

Monday, July 12, 2004 11:15 AM by Paul Wilson

# re: UI Mappers: A Common Scenario

Paul,
Have you read Kathleen Dollard book on Code Generation in .NET? It is exactly what she tries to provide with XSLT trasformation. It is a wonderful read:

http://www.amazon.com/exec/obidos/tg/detail/-/1590591372/ref=olp_product_details/102-8629871-1928918?%5Fencoding=UTF8

Maxim
[www.ipattern.com do you?]

Monday, July 12, 2004 12:54 PM by Maxim V. Karpov

# re: UI Mappers: A Common Scenario

I've seen good things about Kathleen's book, and I know she's a great speaker personally, but I haven't really followed her code gen stuff. I'm just not a big fan of the XSLT style -- not to say its bad or flawed -- its just not my style so I haven't bothered with it. CodeSmith works great for my code gen needs already, and I don't have many needs with my mappers. :) I do think its great that she and others have really tried to push code gen though, since I do think code gen and/or mappers are preferable in most cases.

Monday, July 12, 2004 5:32 PM by Paul Wilson

# re: UI Mappers: A Common Scenario

XAML, XUL, databinding, etc... are showing a strong shift to more loosely coupled UIs. I agree with you Paul that there is room for another layer of abstraction that compliments this shift quite nicely. Thinking of a layer just a bit higher than html, for example,

<TextBlock>
<Heading/>
<Text/>
<Image>
<Subtitle>
<Image>
<Text/>
</TextBlock>

In this case there is no formatting...just good ole contextual XML. A TextBlock control would dictate fonts, spacing, color, etc... A lot can be done with XSLT, but with a Java/Flash/.Net control you could include some rich behavior as well...such as images fading in, Editable grids, or whatever.

Think of defining your pages in the above markup. You can then spit it out into whatever technology you built a component set for.

The more repetitive and similar your Views are the more beneficial this technique would be to you.
-andy

Monday, July 12, 2004 7:14 PM by Andy Hopkins

# re: UI Mappers: A Common Scenario

I think that like O/R mapper which doesn't create database, UI mapper doesn't need to create UI either. It must <b>MAP</b> between businness entity ant UI, handle security issues like hide buttons, grids, and so on, may be validation.
Still the problem is: how to do it with 3-party controls?

Tuesday, July 13, 2004 2:09 AM by Anatoly

# re: UI Mappers: A Common Scenario

Paul,

Where was this idea 6 months ago when I started toying with the idea?! I have been working on this concept myself for about 6 months. Now I don’t have the skills that you have and this is why I am not 100% done but I am almost there. I started looking at different O/R mappers about 6 months ago, the main ones I locked at where Olymars and LLBLGen Pro.

Olymars is cool as it also generates lots of controls and GUI objects for you….but I did not want to use stored procedures. Using LLBLGenPro was the best solution for me as it uses dynamic SQL. I am writing reporting apps and did not want to create Procs on my servers.

Anyhow the approach I took is a follows.

1. Create LLBLGen Pro Project . The new version of LLBLGen Pro supports custom properties. I store custom properties in the project file and these are used in step two. Generate code using adapter config this will generate 2 projects.
a. DatabaseGeneric
b. Database Specific
2. I have a template set that runs in codesmith. I create a custom property browser that will open the LLBLGen project file. I run the master template set and the following projects are created.
a. BL – Business Layer Project
b. WebControls – For each entity I create a custom dropdown, datagrid and repeater
c. WebApplcation – Creates web forms and web form lists for each entity

Bert

email if ya want 7fgi-waja@spamex.com

Tuesday, July 13, 2004 3:13 PM by Bert

# re: UI Mappers: A Common Scenario

I think you hit it on the head Anatoly. The mapper vs generator is a key point.

Tuesday, July 13, 2004 11:10 PM by Andy Hopkins

# re: UI Mappers: A Common Scenario

you are on the right track. i did a bit of this with a template{x} product i wrote (http://www.cybral.com/solutions/templatex.htm) and people were always asking for the UI piece...plus it demos much better to senior managers and above. O/R Mappers are typically too abstract for management where a nice wsiwyg does well for the "abstract-challenged" ;)

-Mathew Nolton

Wednesday, July 14, 2004 3:25 PM by Mathew Nolton

# In the real world...

Thursday, July 22, 2004 11:58 PM by TrackBack

Leave a Comment

(required) 
(required) 
(optional)
(required)