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?

6 Comments

  • 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.

  • 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.

  • 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.

  • 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?

  • 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

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

Comments have been disabled for this content.