Re: Required in .h
Re: Required in .h
- Subject: Re: Required in .h
- From: Ondra Cada <email@hidden>
- Date: Wed, 29 Aug 2001 11:40:03 +0200
Searle,
>
>>>>> Stuppel, Searle @ San Diego Central (SS) wrote at Tue, 28 Aug 2001
15:35:20 -0700:
SS> I know this is probably a basic question, but after a long time of
SS> messing with it, my guess comes down to: Only stuff that other files need
SS> to be able to "see".
Right.
There are others who would recommend to put there _more_ (than "need to
know"). Well, it is relatively harmless, *BUT*
- it clutters the header, making it to be a worse reference;
- it complicates maintenance and upgradability, since it "fixes" (in the
sense 'users may count on that') behaviour which could otherwise be freely
changed in next releases.
SS> In other words:
SS> - (BOOL)validateMenuItem:(NSMenuItem *)anItem; is not needed in a .h
SS> - (void)awakeFromNib; is not needed in a .h
As for awakeFromNib, I'd mention it. The thing is that [super awakeFromNib]
is normally not called (since it would need an explicit checking whether it
is implemented in superclass or not); therefore, if somebody will subclass
your class, he would need to know whether there is some awakeFromNib in case
he would need to implement his own.
SS> Can someone give me a hard and fast rule for this if such exists?
It does not, but your first guess was right: put there anything needed for
usage and subclassing of your class. It can be quite informal -- comments
will do, if there happens to be reason not to declare something.
For bigger projects it is sensible to #define exceptions, notification, and
defaults, too (and comment on their usage).
The only thing the _compiler_ does need though are the properties in case
the class is to be subclassed (and the list of protocols if
conformsToProtocol: should work properly). The method list is more or less
optional -- just the very same way as function headers are optional in plain
C (if you don't use them, problems with type conversions can occur).
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
References: | |
| >Required in .h (From: "Stuppel, Searle @ San Diego Central" <email@hidden>) |