Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem with compiling abstract class with CW (MAC OS X)



At 11:13 AM -0700 11/26/02, Greg Guerin wrote:
If some maintainer can't figure out that moveBy() should be implemented by each inner class, they probably shouldn't be doing maintenance.

Even the most competent programmer can make a dumb mistake. And even the most incompetent programmer can be assigned to do maintenance, whether they "should" be or not. The fact that I may have a bonehead co-worker has no bearing on whether moveBy() *should* be declared abstract.

There would be doc-comments concisely explaining this abstract-to-anonymous relationship, too.

Yes. Making moveBy() a do-nothing non-abstract method is a workaround to a compiler bug, and like any workaround should be clearly documented. Given a choice, I would prefer not to have to use the workaround at all.

If a do-nothing method is insufficient, throwing a RuntimeException in the superclass's default method body prevents the method from being used in practice, yet avoids the 'abstract' qualifier. I've used this approach before.

Good point. It applies any time you have a method that you can't declare abstract, but that you want never to be invoked.

Defensive programming of a different sort.

Yup -- runtime rather than compile-time. Sometimes runtime checking is the best you can do -- hence things like asserts. Throwing the RuntimeException as you described is essentially the same as having an assert that always fires.

--Andy
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: problem with compiling abstract class with CW (MAC OS X) (From: Greg Guerin <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.