Learning Cocoa - A Rant
Learning Cocoa - A Rant
- Subject: Learning Cocoa - A Rant
- From: Chris Gehlker <email@hidden>
- Date: Sat, 04 Aug 2001 18:05:23 -0700
/RANT ON
I was working my way through "Learning Cocoa" the other day when all of a
sudden I hit example 13-4 starting on page 287. The method,
updateInfoWindow(), basically handles a tabbed view although for some reason
the user interface is a PopUp.
The method is a horrible nested switch statement that exposes every detail
of every panel. I was shaking my head and asking myself "Is this the
canonical way of handling tabbed views in Cocoa?" What happened to
encapsulation? How come this code feels like it should be written in Pascal?
I couldn't help but compare this with the way PowerPlant handles tabbed
views, i.e. using OO principles. There if I want to add a new tab I don't
have to revisit the tab handling code.
I was hoping the authors of this beast just had a brain fart and that's not
the way it's done. I checked out NSTabView so I'm reassured. Still it
rankles that this kind of stuff is presented as an example for Cocoa
newbies.
--
When I was a boy I was told that anybody could become President. Now I'm
beginning to believe it. -Clarence Darrow, lawyer and author (1857-1938)