Do Not Hand Code User Interfaces

I've hand coded a fair share of user interfaces in my time. Whether it's a Win32 application in C++, or a Swing UI using GridbagLayout?, I think better results can always be achieved by using a visual editor.

I believe there is too much overhead in trying to create and align controls manually in code. This overhead comes from having to create the controls, specify their positions, and implement the correct resizing and alignment behaviour. Combined with the Edit -> Compile -> Run workflow and the developer is slowed significantly.

Contrast this with a visual editor like NetBeans' Interface Builder (formerly Matisse). The developer can drag controls from a palette onto a form, and in a matter of seconds these controls can be positioned and aligned correctly. None of this requires any compilation or runtime execution, and the developer has instant visual feedback.

In the past I was of the opinion that visual tools were not good enough, and that hand coding the UI gave greater control to the developer. But I don't believe this is true any more. The tools have got better, and it is still possible to hand-code subsets of the UI if necessary.

In the past I have compared interfaces written by hand with those created by a visual tool, and the difference is clearly noticeable. The hand coded UIs have strange resizing and alignment behaviour, and generally feel like they've had less attention paid to them.

I think this comes down to the speed of development. A developer using a visual tool has much more time to refine and polish their interface, tweaking every last control visually until it's "just right".

On the other hand, a developer hand coding an interface will spend so much time on the basics that they get frustrated and tire quickly, finishing as soon as the UI is "good enough".

It's worth noting that when it comes to the web, I've only ever hand coded interfaces in HTML, but I'm sure the same principle holds.

Your thoughts? Do you think DoNotHandCodeUserInterfaces is a reasonable guideline?

MikeWeller.


I think ItDepends on the application itself. For example, the user interface for Vi would not benefit from visual editors. Visual interface tools are good for things like dialog boxes, not so good for other things. It's basically the same problem as wizards have, ideal for some situations, wrong for others, and in any case you'll always want to be able to access the actual code at some point. --LayneThomas


Most of these issues are covered in CoordinateVersusNestedGui. I think there are places for both kinds of designs. And I wish more visual designer tools would adopt "stretch zones" to make re-sizable windows that give more widget space.


Can you imagine programming a User-Interface using front-panel toggle-switches? To aspire to ProcessImprovement, one must use ProcessImprovementTools. -- DonaldNoyes 20071208


CategoryApplicationDevelopment CategoryCodingIssues CategoryAntiPattern


EditText of this page (last edited January 10, 2009) or FindPage with title or text search