[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unimplemented methods
Re: Unimplemented methods
Tue, 20 Nov 2001 14:54:12 +0000 (GMT)
> would it be possible to raise an exception whenever a method is invoked which
> is not yet implemented (in GNUstep)? Ie. NSWorkspace's
> - (NSImage *) iconForFileType: (NSString *)fileType
> and similar methods which return nil in all cases.... This would help a lot!
hmm ... are you sure you *really* want that ... I don't think so ...
typically what happens is - code coming from MacOS X will try to set some
properties of objects ... properties which are unimplemented in gnustep
... say that you call [NSPopupButtonCell -setPreferredEdge:] ... the
preferred edge is unimplemented in gnustep ... but you don't want the
library to raise an exception (aborting your application) just for that
... you rather want it to ignore the call to setPreferredEdge: and go on
... you can still use the application even if the preferred edge of the
popup is not the one you'd set it to be on MacOS X ... who cares ... you
first want your application to work and be usable, then if you're
unsatisfied with the preferred edge, you can contribute code to gnustep to
implement it :-)
so - for many methods, typically for setting unessential properties of gui
elements, what we do is ... we implement the methods to do nothing, and
ignore the calls ... that allows code coming from Mac OS X to run.
for methods doing essential things which are missing, I agree we should
warn the programmer ... but why implementing the method (thus removing any
compile-time warning if the method is called) to raise an exception (thus
crashing the application at runtime if the method is called) ... that
looks like pretty stupid ... the man doing the port will have no way to
know there is a problem with that method when he's compiling ... and still
the application will crash with an exception at runtime when the method is
I think the methods shouldn't be there at all ... [NB: that will
automatically raise an exception at runtime if you try to call them
regardless of compiler warnings] ... giving the benefit that the compiler
will complain at *compile* time telling you you're calling a method which
is not implemented in gnustep ... so you know you have to do something
about it (implement the method yourself and contribute it, try persuading
some other developer to do it for you, or work around the problem in your
code ...) ...
in conclusion, my opinion for unimplemented facilities is:
- methods setting unessential properties of gui elements should be there
with an implementation doing nothing, so that ported applications still
run properly even if they are unimplemented;
- methods doing something essential should *not* be there at all.
they should be commented out in the header file as well.
that will help people trying to port code, so they know immediately
what methods will cause problems, because the compiler will emit
warnings when they call the methods.