Re: Introspect whether setCharacterEncoding is present..
Martin Cooper <[email protected]> Wed, 13 Oct 2004 19:57:24 -0700 (PDT)
| Newsgroups | gmane.comp.java.advanced-servlets |
|---|---|
| Message-ID | <[email protected]> |
--- Nic Ferrier <[email protected]> wrote: <big-snip/> > > What I am asserting is that the statement "Exceptions must not be used > for control flow" is incorrect. There are situations: > > - where you have to use Exceptions for control flow > - where you should use Exceptions for control flow > > These are: > > - multi method FSMs Maybe you should try Nice (http://nice.sourceforge.net) for these instead. ;-) -- Martin Cooper > > - predicating behaviour on assertion by Exception > > > Clearly if you can't do something any other way it makes the only > alternative the preferred way. But perhaps you mean it's not > preferential but we have to do it. > > > > Yes, but was the example that triggered this entire debate one of > > those? Admitted, it's the only obvious way to check if the class > > exists in the current JVM, but Class.forName() is really intended to > > get an instance of a class if you expect it to be there, and not as > > a mechanism to check if the class exists. > > The only obvious way? Or the only way? > > > > The fact that the Java standard API doesn't give you a better way to > > check for the existence of a class without throwing an exception (it > > doesn't, right? Just checking.) does NOT make the suggested way, The > > _Right_ Way. It just makes it a convenient hack to get around the > > limitations of the existing API - also known as, The Only Way. > > What? What planet are you living on? There is no other way. It's not a > cruddy way to do it: it's THE way to do it. What are we to do when > writing programs? Not do something because it's inelegant? > > Inelegant and inadvisable are different things. > > > > What is a "non-local exit"? What is an "If" check? And what is the > > requirement here? All we're looking for, is the existence of a > > class. > > Non-local exits got included in this thread because the suggestion was > made that Exceptions should not be used for control flow. Non-local > exits were an obvious and legitimate use for Exceptions that made the > suggestion a lie. > > > > > Right. You really _really_ don't like support engineers, do you? > > (No, I'm not a support engineer either, but I like to think of > > myself as the sensitive type) > > Actually I do a bit of that from time to time. I'm a hacker. People > hire me to sort stuff out. I have to read people's code and manage it > all the time. And I find that reading the code rather than the log > statements is the most sensible tactic. > > There really is nothing wrong with goto, Sun call it continue or break > and they use it quite often in JDK code I'm told. > > > > And as far as the performance aspect goes, I don't disagree with Nic > > there. Most times, the effect of throwing Exceptions, on > > performance, is negligible. > > Good man. > > > The only other way I can see of doing Charles' code is this: > > boolean exists = false; > try > { > Class.forName("com.bull.LoadOf"); > exists = true; > } > catch (...Exception e) > {} > > if (exists) > ...; > > > I prefer Charles' way because there is something in the catch > handler. Empty catch handler's are bad IMHO (and yes, there are *real* > reasons why that is so). > > > > The reason I'm being so pugnacious about this is three fold: > > 1. I believe that it is dishonest to impose stylistic restrictions on > use of computer languages > > 2. I find it patronizing when people suggest that certain things make > programs too difficult for support people or newbies or old people > or people with glasses or short people or whatever > > 3. I've been implementing Scheme recently in GNU C and continuations > are really cool and make you appreciate the whole role of the > stack. > > > Nic > > > > Before posting a question, try to find your answer here: > <http://www.egroups.com/links/advanced-servlets> > Announcements should go to: [email protected] > To Post a message, send it to: [email protected] > To Unsubscribe, send a blank message to: > [email protected] > Yahoo! Groups Links > > === message truncated === __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo ------------------------ Yahoo! Groups Sponsor --------------------~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Before posting a question, try to find your answer here: <http://www.egroups.com/links/advanced-servlets> Announcements should go to: [email protected] To Post a message, send it to: [email protected] To Unsubscribe, send a blank message to: [email protected] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/advanced-servlets/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/