Re: Redeclaring overrides
Re: Redeclaring overrides
- Subject: Re: Redeclaring overrides
- From: Ondra Cada <email@hidden>
- Date: Sun, 19 Aug 2001 12:07:16 +0200
Chris,
>
>>>>> Chris Gehlker (CG) wrote at Sat, 18 Aug 2001 19:00:35 -0700:
CG> Well, that's just too short, at least for me. If there were a style that
CG> said "Declare everything you define, even if it's an override" I could
CG> understand. But that's not what "Learning Cocoa" is doing.
I have never read the thing, but there always was -- at least so far as I
understood -- the following *unofficial* standard in OpenStep:
"Declare in header
- all new methods;
- plus those overridden(*) ones which need some explanation for anybody who
might be using/subclassing your class;
- do not clutter the header by other ones"
(*) Actually, not just an override: might be also an implementation of
something from an informal protocol -- those things do not need to be in
header as well.
CG> If there were a style that said "Declare everything that you override if
CG> it's not likely that most applications will override that method I could
CG> understand that as well. But awakeFromNib?
Well, unless there *IS* some convention I've missed, with awakeFromNib there
is a problem that is is somewhat unclean whether to call [super
awakeFromNib] or not. Actually, the super's implementation gets never called
in standard Apple's examples -- and thus probably neither in majority of 3rd
party awakeFromNibs.
Now, that's an *EXCELLENT* reason why it is *very* interesting to know
whether a class you are about to reimplement contains an awakeFromNib or not.
(Of course, a firm convention to always call "if [[self superclass]
instancesRespondToSelector:@selector(awakeFromNib)]) [super awakeFromNib];"
would solve the problem so that awakeFromNib would not need to be placed in
header /unless there are other reasons to document it. of course/. There
seems to be, alas, no such convention, though.)
CG> Furthermore the book declares awakeFromNib in exactly one sample program
CG> and overrides it in many.
CG>
CG> I'm still very confused.
I am afraid that's the exact state of mind the writer(s) of Learning Cocoa
were in :(
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc