UIObjects.Net

time to read 4 min | 602 words

I'm currently working on something similar to NakedObjects, a UI framework that should save you the time building UI.

Why am I building this?

  • NakedObjects dotNet implementation does not work on my system, throwing java.lang.ExceptionInInitializerError (WTF?? In a .Net application?)
  • I checked the Java implementation and I really like the idea, but not the implementation.
  • As far as I understand the .Net port, they use the same code {one of the JVM for .Net ?} to run it, which means that I've to write ugly looking code to make it work [Ugly meaning Java-style, which is fine, but I like my C# code to adher to the .Net naming conventions.]
  • The UI is horrible.
  • I want to experiment a little with Reflection & UI design, both of which I've very little experiance at.
  • If I'll finish it, that would be a cool thing to have.

 

Basic design is as follows:
Attributes:

  • [VisibleObjectAttribute] - decorate a class/struct. Means that this an object that is visible on the UI. Several built-in objects are treated by the framework as if they'd this attribute (string, all numeric types {short, int, double, numeric, etc}, DateTime, Enum).
  • [ActionAttribute] - decorate a method. Means that this is a method that is exposed to the UI.
  • [ValidateParametersAttribute] - decorate a method with [ActionAttribute]. Points to a method that validate the parameters for a the decorated method. This ensure that the method would get parameters in a consistent state.
  • [TitleAttribute] - decorate a string property. Used to get a nice name for an instance of an object.

  • [CoreObjectAttribute] - decorate a class/struct. Inherit from VisibleObjectAttribute, means that the object is visible as the root level of the application.

  • AppletCreatorAttribute - decorate a class/struct. Signify that this type supply it's own UI and should be ask to do so when presented to the user.

Classes:

  • VisibleObjectContainer - contain the info regarding a type decorated with VisibleObjectAttribute {FriendlyName, Icon, Type, etc}.

  • VisibleObjectInstance - contain the info about an instance of a type decorated with VisibleObjectAttribut. This is used everywhere to work with the object. This class also decide what Actions can be taken on a the object, based on its state and on the parameters.
    For instance, if you Act(“New name“) on an VisibleObjectInstance that has a method:
    [Action] string SetName(string NewName){}
    Then it will be called and the return value will be returned to you.

  • Action - wraps a method decorated with [ActionAttribute], allows to query if it's valid on an object, get the nice name for it, etc.

  • AppletFactory - Create the UI representation of a VisibleObjectInstance. It does so by checking a few builtin types to get the default implementation, then check if the type provide its own UI (through AppletCreatorAttribute), if not, then pass it to a default applet creator that read all the public properties/fields and gives you a form that you view/change it.I

Interfaces:

  • IAppletCreator - any type that want to create its own UI need to provide an implementation of this interface.

That is all that I've right now.
Some note about terminology:
Applet is my term for a piece of the UI that may stand on its own {in the framework, represented as Control} or may be hosted in another Applet / the main form.

Some UI consideration:

  • How will the UI look? I thought about dockable panels to represent the types, with the ability to drag icons to each other. But wouldn't it create a lot of clutter?
  • Actions on VisibleObjectInstances will be access via right click? A menu?
  • How to deal with Actions that require parameters? Pop another applet? What about complex parameters {Customer, Order, etc}.

Currently I'm working with FxCop to clean up the code, I can't maintain a naming convention in my own code, it seems.

P.S
Resharper is goodness.