views:

268

answers:

2

Hello,
Do you know about a library that allows us to generate UI by just stating that it should be generated?

I think there must be a person who have implemented a mechanism allowing us to transform code like this:

class Main {
    @Command
    int add(int a, int b) {
        return a+b;
    }
}

into, say, a dialog with 2 text fields and a button? Or into a webform? You've got the idea, right?

The type of UI and the language doesn't matter, if it allows us to simply say, "This should be a command" without those lots of XML files scattered all over the application.

And, btw, what do you think about this kind of meta-programming?

+2  A: 

I have lost count of how many times I've seen variations of this implemented over the years. The common theme is annotating/supplementing your core obejcts with metadata and try to generate a UI on-the-fly from there. All attempts I have seen always end up with user interfaces that even the creator have problems liking. It also seems like there's no amount of meta-data you can add that will make these UI's nice.

The only exceptions that I have ever recalled seeing work half-decently is the key-value editor that lets you edit values for a fixed set of keys (this also works in a tree structure).

krosenvold
I've seen this pattern a few times in the insurance industry which is heavily forms-driven. It works, but it's ugly.
hbunny
+3  A: 

Have you looked at Naked Objects?

Andrew Swan
Thanks, it seems to be exactly the thing I'm looking for.
AnSGri
Does that mean you can make this the accepted answer? ;-)
Andrew Swan