Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Wrapping my head around formal protocols
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrapping my head around formal protocols



> A programmer instantiating a class that is _by_design_ abstract is a
> programming error and will result in an incorrect program. I think
> there is enough reason to want to stop someone from doing it, don't
> you think?

No - if a programmer makes a mistake you want them to know about it, clearly
and distinctly, with a good indication as to what the error is, right ? Since
messages to 'nil' in ObjC are legal then if someone writes this:

	myObject = [MyAbstractClass new];
	[myObject aMethod];

If you prevent the class from being instansiated then that code will run but
do nothing. On the other hand, if you let it instansiate then the program
stops with "MyAbstractClass does not implement method aMethod" when it hits
the second line.

Preventing programmers from doing the wrong thing is, in most cases, far less
important than communicating to them what they have done wrong. If you
can do both great, if you get a choice of only one then pick the latter as
it makes fault-finding a lot easier.

Well, thats my opinion anyway....

-pete.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Wrapping my head around formal protocols (From: Dado Colussi <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.