Re: "Cocoa Fundamentals Guide" Clarification
Re: "Cocoa Fundamentals Guide" Clarification
- Subject: Re: "Cocoa Fundamentals Guide" Clarification
- From: Mike Abdullah <email@hidden>
- Date: Mon, 19 Jan 2009 19:44:40 +0000
Just write your code in Obj-C. When you have a finished application,
then start profiling performance. If this shows that calling some
methods is slowing things down, consider changing them to a function.
However, note that you are rather unlikely to run into this. Message
dispatch is pretty damn fast, and is fairly rarely the cause of
performance bottlenecks.
i.e. DO NOT ATTEMPT TO OPTIMISE PERFORMANCE TOO EARLY!
Mike.
On 19 Jan 2009, at 19:00, Mohan Parthasarathy wrote:
Hi,
I am reading the section "Functions, Constants and Other C Types",
in the
Cocoa Fundamentals Guide (
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/chapter_2_section_2.html)
and a little confused about the wording in this section.
The following list offers some guidance on using C types in the
definition
of a custom class:
■ Define a function rather than a method for functionality
that is often
requested but doesn't need to be
overridden by subclasses. The reason for doing this is performance.
In these
cases, it's best for the function
to be private rather then being part of the class API. You can also
implement functions for behavior that
is not associated with any class (because it is global) or for
operations on
simple types (C primitives or
structures). However, for global functionality it might be
better―for
reasons of extensibility―to create
a class from which a singleton instance is generated.
I am slowly getting to speed on Objective C and Cocoa programming. I
have
written a few classes and is all written completely in objective C.
In the
classes that i have written i realize that i have a init method and
at most
two other methods that are used by other objects. But there are other
methods in the classes that are mostly private i.e not used by other
objects
(i relaize that all methods defined in the .h file are public). I
have not
yet subclassed my own classes just the system provided classes.
Does the word private in the guide refers to the same meaning as
"interfaces
that are solely used within a class and not used/extended by other
"classes"
? Do i have to really care about this while writing my code or just
ignore
and write everything in objective C ? If i have a chunk of code
written in
"C" that i want to reuse, i guess i can do that if it is not too
much of a
pain to convert to objective C. But then the word "performance" is a
little
confusing in the above paragraph. Sorry, if i am reading it too
literally..Any clarification would be appreciated..
thanks
mohan
_______________________________________________
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
_______________________________________________
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