My First Yellow Box App
Volume Number: 13
Issue Number: 9
Column Tag: develop
My First Yellow Application
by Éric Simenel
Since most of us are in the process of exploring the OpenStep (Yellow Box) framework
and its development environment, it's likely that we are going to encounter the similar
pitfalls. I thought it would be useful to describe my first experience at writing
something more ambitious than a simple snippet, so that you could benefit from my
trials. To make the most out of this article, you'll need to already have some knowledge
of Yellow Box. This article is not a tutorial, it's more like a journal...
First, let me give you a little background. I've been programming for the past 17
years (13 on Macintosh) using a lot of languages (in order of appearance: FORTRAN,
6502 asm, BASIC, COBOL, LISP, Pascal and Object Pascal, 68K asm, C and C++,
PowerPC asm and Java), and a lot of environments and Operating Systems (micros,
minis and mainframes).
As far as frameworks go, I've only used a very little bit of MacApp and more of ODF
(the late OpenDoc Development Framework), but mainly I've used the Mac Toolbox
when developing company and personal stuff. The main reason is that I've been
developing with it for so long that it's just like an old friend; you know what you can
ask it to do and what you'd better not.
Since I've been doing Object Oriented Programming for the last 6 years, I've always
regretted a little bit that the Mac Toolbox doesn't have OO APIs. Of course, I could have
used a framework but this adds an extra layer which you sometimes appreciate and
sometimes don't.
Well, with Rhapsody, it's OOP from the word go, so no more excuses.
At first, the Objective-C syntax with all of its "["s and "]"s looks really different, but
I'd say that after a day or two, you don't even think about it anymore. And anyhow, the
Developer Release or the Premier Release will come with the Objective-C modern
syntax which will be more familiar to the C/C++ developer.
Although a lot of people admire Interface Builder (IB), and it's indeed a very nice tool,
I, for one, think that the real power comes from the Yellow Box framework. When I
developed my first Yellow application, I spent maybe 5-10% of my time in IB and the
rest in Project Builder (PB). I must add that if IB didn't exist, we would need to spend
an incredible amount of time writing source code to do what it does since this tool is
much more than a simple graphic user interface designer tool, but more on that
below...
While writing my sample code, I learned quite a few things which I didn't find
explicitly in the documentation, so I thought it might be useful to share them. I must
add that I later found some (but not all) of this information in documents which I didn't
possess at first, and since I believe this will be the case for most of you, and that,
anyway, who reads the entire documentation before starting coding, it's still useful to
have those points collected in a useful way, i.e. this article.
I guess readers of the late develop magazine will remember that I collect Comics
Books, Comics in short, and my non-trivial sample code is the port of an existing
Comics Database Management Macintosh application to the Yellow Box. There is an
additional document "The way I collect Comics" in the development folder, which
explains why I designed the user interface the way it is. This article deals with the
"how" I designed it.
The development folder containing all the source code, interface files, project files,
etc. is on the Rhapsody Developer Release CD, and will also be on our web site, whose
address is not known at this date but which I trust you shouldn't have too much
difficulty to find.
This article contains extracts of the source code only when relevant, you might find it
useful to read the entire source code along with this article.
What's in a Nib (NeXT Interface Builder) File
Everything which has been created in the nib while using IB (i.e., every icon which
you see in the "Instances" panel), will be instantiated when the nib opens.
That means that when your application launches, its main nib is opened, all objects