Skip navigation.
 
mlRe: Virtual concept in Objective-C
FROM : Michael Watson
DATE : Wed Jul 19 20:47:31 2006

I'm not a big fan of putting the standard methods in the header file, 
either.

Let's say a co-worker has a class called "FVAwesomeWindow". The 
header file indicates that it's a subclass of NSWindow. I don't need 
to see -initWithContentRect:styleMask:backing:defer: and -dealloc in 
the header file as well. It's an NSWindow subclass, so either those 
methods exist and are being overridden, they're not being overridden 
(and still exist, obviously), or there's a different method do 
whatever (which would then appear in the header file, because it's 
not a method in the common NSWindow class). E.g.,

- (void)initWithContentRect:(NSRect *) withSomeAttribute:(Something *)
foo; // FVAwesomeWindow is a special window is always a panel that 
floats and has XYZ attributes, but we always want to set 
SomeAttribute at creation, so this is how we roll.

But if the FVAwesomeWindow just uses the standard NSWindow init 
methods, there's really no reason to clutter up the header file with 
that information. We know it's there, it's an NSWindow subclass. The 
absence of any special custom init method(s) means that it uses the 
normal init methods.

My thoughts, anyway.


--
Michael Watson

On 19 Jul, 2006, at 14:34, Scott Ribe wrote:

> Well, that's a matter of style. Argument 1: all methods implemented 
> should
> be declared in the header, so that by looking at the header one can 
> tell
> what methods a class implements--in theory I agree. Argument 2:
> commonly-overridden methods (think dealloc for instance) just 
> clutter up the
> header without providing any real info.

Related mailsAuthorDate
mlVirtual concept in Objective-C Vinay Prabhu Jul 19, 08:32
mlRe: Virtual concept in Objective-C Shawn Erickson Jul 19, 08:40
mlRe: Virtual concept in Objective-C Dix Lorenz Jul 19, 08:43
mlRe: Virtual concept in Objective-C Finlay Dobbie Jul 19, 13:50
mlRe: Virtual concept in Objective-C Dix Lorenz Jul 19, 14:02
mlRE: Virtual concept in Objective-C Vinay Prabhu Jul 19, 14:04
mlRe: Virtual concept in Objective-C Scott Ribe Jul 19, 20:34
mlRe: Virtual concept in Objective-C Michael Watson Jul 19, 20:47
mlRe: Virtual concept in Objective-C Dirk Stegemann Jul 19, 21:39
mlRe: Virtual concept in Objective-C Chris Stewart Jul 19, 23:04