Guidance for Cocoa's steep learning curve
Guidance for Cocoa's steep learning curve
- Subject: Guidance for Cocoa's steep learning curve
- From: Erik Buck <email@hidden>
- Date: Wed, 14 May 2008 21:19:25 -0400
The obstacles, misconceptions, and prerequisite concepts that need to
be mastered when learning Cocoa vary dramatically based on the past
experience of the learner. I am a very experienced Cocoa programmer.
I am also an author of the thickest Cocoa Programming book and have
another Cocoa book due out real soon. I have some guidance.
To relate my background, I started using NeXTstep (the precursor to
Cocoa) that included Interface Builder and Objective-C and App Kit in
late 1988. I had heard of object oriented programming but didn't "get
it". I had attended a one day seminar on "C with Classes" which later
became C++. I left the seminar no wiser than when I arrived. I had
worked for eight years with C and a variety of assembly languages. I
had been using Ada for a year.
I became excited about NeXTstep software development, worked on many
hobby projects, and from 1991 on I worked extensively with NeXTstep/
Openstep/YelowBox/Cocoa as well as C++ and many other technologies. I
founded a company in the early 90s and developed an industry leading
application. I sold the intellectual property to a Fortune 500
company in 1996, and my company continued to work in the industry
until late 2002. I am now "Senior Staff" for a different Fortune 500
company in a related industry.
Here is my guidance based on some arbitrarily chosen categories of
learners:
=== If you have never programmed before
1) Learn any programming language (it may seem hard, but every 'real'
programmer knows many languages and you have to start somewhere)
2) Learn C and at least learn to recognize low level operations like
bit manipulation, pointers, intrinsic types, pointers to pointers,
pointers to functions, etc. Without this, you will be lost and
dangerous when writing Cocoa programs in Objective-C.
3) Learn Objective-C. It takes about 1 day for an experienced C
programmer.
4) Start the long process of learning the Cocoa frameworks, the C
standard library, and some of the Unix libraries.
4A) Learn Cocoa conventions and common patterns. These are not
optional. Clear understanding of the following is required to write
graphical Cocoa applications: two stage allocation and initialization,
designated initializers, memory management, selectors, dynamic
messaging, accessors, the responder chain, delegates, target/action,
data sources, archiving & unarchiving (e.g. freeze dried objects
in .nib files), the view hierarchy, key and main windows, and above
all the Model View Controller pattern.
4B) Study Apple's sample applications, work tutorials, experiment, and
build a few hobby projects.
=== If you are primarily an experienced "dynamic" language programmer
(perl, Ruby, Python, Smalltalk, TCL, etc)
1) Learn C and at least learn to recognize low level operations like
bit manipulation, pointers, intrinsic types, pointers to pointers,
pointers to functions, etc. Without this, you will be lost and
dangerous when writing Cocoa programs in Objective-C.
2) Learn why C and therefore Objective C use a pre-processor with
separate headers and separate implementation files. Come to grips
with the edit, COMPILE, link, debug cycle.
3) Learn Objective-C. It takes about 1 day. You will realize the
Objective-C is very dynamic and flexible but has its own idioms.
4) Start the long process of learning the Cocoa frameworks, the C
standard library, and some of the Unix libraries.
4A) Learn Cocoa conventions and common patterns. Many will be
familiar to a Smalltalk programmer. These are not optional. Clear
understanding of the following is required to write graphical Cocoa
applications: two stage allocation and initialization, designated
initializers, memory management, selectors, dynamic messaging,
accessors, the responder chain, delegates, target/action, data
sources, archiving & unarchiving (e.g. freeze dried objects in .nib
files), the view hierarchy, key and main windows, and above all the
Model View Controller pattern.
4B) Study Apple's sample applications, work tutorials, experiment, and
build a few hobby projects.
4C) If you object to Cocoa's memory management conventions, learn to
love them because in the world of C, automatic garbage collection can
not solve all of your problems.
=== If you are primarily an experienced C++ programmer (In my
experience you will have the hardest time)
1) Forget everything you think you know about Object Oriented
programming (no offense intended).
2) Break every ingrained C++ habit and idiom because the design
philosophy of Objective-C and Cocoa is exactly the opposite of almost
everything C++ encourages.
3) Learn Objective-C. It takes about 1 day for an experienced C
programmer. You will realize the Objective-C is very dynamic an
flexible. Many patterns and idioms in C++ are unneeded in Objective-
C. Objective-C classes tend to be more high level and straight
forward, and you tend to use fewer of them. You may feel disoriented
without the accustomed "bondage and Discipline" [http://c2.com/cgi/wiki?BondageAndDisciplineLanguage
], but I strongly advise you to learn an appreciation for freedom and
the flexibility to send any message to any object even if the receiver
did not exist when your application was compiled and linked. For
many, an appreciation for Cocoa's undo mechanism breaks the ice.
(although dynamism is ubiquitous in Cocoa)
4) Start the long process of learning the Cocoa frameworks.
4A) Learn Cocoa conventions and common patterns. These are not
optional. Clear understanding of the following is required to write
graphical Cocoa applications: two stage allocation and initialization,
designated initializers, memory management, selectors, dynamic
messaging, accessors, the responder chain, delegates, target/action,
data sources, archiving & unarchiving (e.g. freeze dried objects
in .nib files), the view hierarchy, key and main windows, and above
all the Model View Controller pattern.
4B) Study Apple's sample applications, work tutorials, experiment, and
build a few hobby projects.
=== If you are primarily a Java programmer
1) Learn Objective-C. It takes about 1 day. You will realize the
Objective-C is very dynamic and flexible. Many patterns and idioms in
Java and C# are unneeded in Objective-C. You may feel disoriented
without the accustomed "bondage and Discipline"[http://c2.com/cgi/wiki?BondageAndDisciplineLanguage
], but I strongly advise you to learn an appreciation for freedom and
the flexibility to send any message to any object.
2) Start the long process of learning the Cocoa frameworks, the C
standard library, and some of the Unix libraries.
2A) Learn Cocoa conventions and common patterns. These are not
optional. Clear understanding of the following is required to write
graphical Cocoa applications: two stage allocation and initialization,
designated initializers, memory management, selectors, dynamic
messaging, accessors, the responder chain, delegates, target/action,
data sources, archiving & unarchiving (e.g. freeze dried objects
in .nib files), the view hierarchy, key and main windows, and above
all the Model View Controller pattern.
2B) Study Apple's sample applications, work tutorials, experiment, and
build a few hobby projects.
=== All
Once you understand in principal how all of the basic Cocoa patterns
are implemented, learn about Key Value Observing, Bindings, Core Data,
etc. These use advanced patterns that seem like magic until you have
mastered the basics.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden