Views from Phanfare CEO and Co-founder Andrew Erlichson

Link GUI Development on the Mac vs. the PC


GUI apps are like sausages, it is better not to see them made. Apple and Microsoft have a fundamentally different approach to sausage production. Visual Studio integrates its GUI designer right into the IDE. On the Mac, you use Interface builder, a separate application, to create your GUI elements.

The integration of GUI design within Visual Studio follows from Microsoft’s approach to GUI synthesis. The drag-and-drop GUI designer generates C# code that is then compiled into your application, and that code can be edited by the developer. Apple’s Interface Builder generates data files that are read in at runtime to display GUI elements. Considering that the code generated by Visual Studio’s GUI builder is in fact data to the Common Language Runtime after it is compiled into IL, there would seem to be a general equivalence between the techniques. One person’s code is another person’s data. But in terms of developer workflow and customization, the Visual Studio approach is far more efficient.

Here is how you create a button in each environment.

Visual Studio:


    1. Drag a button onto the window
    2. Double click the button
    3. Write code

Xcode/Interface Builder:


    1. In Xcode, go to your window controller header file, add two lines for your outlet and action
    2. Switch to Interface Builder
    3. Drag a button onto the window
    4. Change tab to the class browser
    5. Find your window controller and re-read the file to get your updates
    6. Change back to the object browser
    7. Apple-drag from the window controller instance to the button
    8. Select the outlet you defined before and click 'Connect'
    9. Apple-drag the button onto the window controller instance
    10. Select the action you defined before and click 'Connect'
    11. Switch back to Xcode and into your window controller code file
    12. Add the action method definition and write code

I soon came to dread the UI design work involved with Phanfare Photo for the Mac. The Mac may look nice on the outside, but it is not so nice on the inside.

There is an argument for separating out the GUI design component to a separate application. Ideally, this would allow someone more artistically gifted than I am to do the GUI work and hand me back a bunch of GUI design data objects with a big red bow. But for this separation to work, the GUI designer (and I mean the person) needs to be able to work without requiring fine-grained communication with the application engineer (that would be me).

The Apple approach fails here in that the programmer must muck around in the designer stuff to get anything working (sometimes not getting the behavior quite right), and because the set of built-in GUI controls is so limited that the GUI designer must constantly ask the programmer to create custom controls. There really is nothing wrong with the idea of separation, if well implemented. Microsoft’s new venture into the designer/programmer split with Avalon and their designer tool Sparkle looks promising.

There are two parts of GUI design: the ‘fun stuff’ (laying out the UI) and the ‘boring stuff’ (implementing custom controls/behaviors). That was the layout, now on to the behavior:

As I said, in Visual Studio, the GUI designer generates code that you can tweak by hand if needed. In Interface Builder, serialized objects are written out to be loaded when your application runs. This means that if you don’t like the way Interface Builder does something, you have to rewrite your entire GUI by hand (something I found myself doing with shocking regularity).

One of the nice features of.NET is that it has dozens of built-in controls (over 100 in the latest version) and thousands of custom controls built by users. And because controls in .NET are expressed in text-based code, they are easy to tweak and display on web pages, making for a vibrant user community.

The Mac, on the other hand, comes with a very limited set of controls. There are the basic buttons, grid views, etc, but for anything more than a text editor this isn’t enough. Interface Builder provides about 25 built-in controls (they didn’t even get a date picker until Tiger, and even then it’s almost unusable!) and with the size of the Apple developer community it’s hard to find anything on the net.

In the end, I found myself always writing my own controls. Now, to be fair, I had to do this occasionally in .NET too, but with far less regularity.

In the end, both Apple’s approach to GUI design and Microsoft’s can produce modern GUIs, but Apple’s approach required more effort on my part and significantly more hours spent in the not-so-sweet-smelling sausage factory.

Viewing 5 Comments

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus

    Back to Phanfare blog home »

© 2007-8 Phanfare, Inc.