Re: Introspect whether setCharacterEncoding is present..
Nic Ferrier <[email protected]> 13 Oct 2004 11:19:36 +0100
| Newsgroups | gmane.comp.java.advanced-servlets |
|---|---|
| Message-ID | <[email protected]> |
<[email protected]> writes: > > If your code happens to be a large FSM > > then you are going to need non-local exits in the "Critical Paths" in > > your code. This is the only way to make such code readable, the only > > other way to write it is as one large method. And that isn't a good > > idea (also you might need the method call stack anyway). > > I would still look for other "elegant" ways to do it before falling > down to using Exceptions. Using Exceptions being the easy way out, > tends to also become the most difficult to maintain > implementation. Again, this is _generally_ true, and there > definitely are exceptions (pun not intended this time). There aren't any other elegant ways to do non-local exits. Are you saying that you try to avoid ever using non-local exits? > > No they don't. They CAN make your code harder to read. > > I agree with you, Nic. But not every programmer is as smart as > you. (No, I'm not pulling your leg here. Honest.) Now we get to the root cause (pun intended) of the argument. You believe (and I presume that Endre and others who don't like Exceptions for control flow feel the same) that programmers are more often stupid than not. I don't believe that. I believe that I am no more intelligent than most other programmers. I do believe that programmers are often taught badly or not at all. But I further believe that teaching people to program well is actually not that hard. > But it's better to make the suggestion to not do something, and let > the smart ones figure out where to break the rules, than to suggest > the opposite, and have only the smart ones know when to follow the > rule. > > <snip/> > > This bit of advice comes from having taught peope how to write code, > and seeing the results. Or maybe I've just had some bad students. Maybe there's another problem? /8-> I've taught people as well. In the early days I found I made a big mistake which was to presume that people couldn't handle the things I thought were complicated. They can, you just have to teach them right. And teaching isn't hard, it's just about patience. The programmers I have taught have generally gone on to be succesfull, some are now leading their own teams, some have specialized away from programming but I think they all have a good grasp of the language. Of course, I ended up mainly teaching computer science and not particularly Java. But because they understood the computer science they understood Java. In what environment did you teach? Maybe that has an effect. I've always done on the job training. Week long courses in anything seem pretty futile to me and most of the people I've taught agree. > > And do you really think that Charles' example was hard? > > No. But show this kind of code to someone, tell them it's the right > way to do something, and they're going to end up replacing > "DoSomething()" with a 40 line code block that is going to cause the > person supporting it, to tear his (or her) hair out in frustration, > trying to figure out which of those lines causes the exception. Again, you presume that other programmers are more stupid than you. If people make a mistake then try and correct it and move on. > > These are: > > - multi method FSMs > > - predicating behaviour on assertion by Exception > > You got me on the last one. Hadn't thought about that. The last one is what Charles' example was doing. > > 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. > > Incorrect. Non-local exits don't make it a lie. They only show you > the exception to that rule. I don't believe in exceptions to rules. They're just what people say when they've made a bad rule, eg: string theory. In fact, I generally don't believe in rules that much (eg: string theory). > > 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. > > Right. But sometimes there's external API that does stuff, that you > don't have access to the source-code for. (Let's not start another > "that's why open source is a good thing" debate here. I'll agree > with you anyway). In those cases, you just _have_ to look at logs. Ermmm... if you're maintaining code then you have the code I guess. If you don't have the source you have the class files... if you have the class files you have the source code. > And I hate 'break' and 'continue' more than I don't like > 'goto'. They're like the black sheep in the family dressed in cotton > candy. The people working at Sun aren't necessarily the smartest > Java coders in the world. Remember java.util.Stack? This is really interesting. Why do you hate 'break' and 'continue'? These are necessary things. Do you try to avoid them? How? You seem to be quite a purist. But it's interesting that very purist languages like Scheme and Haskell (have you ever used these?) still have to include something for arbritary exits. Both provide continations. Scheme, Haskell and ML programmers would laugh at this argument. Their reaction might go something like: "How can you use a language which has parts that you hate? Why would you not use all your language's expressive capability?" For those who are interested I've sent a separate message with a little about continuations. > See Nic? I'm really on your side. Hey... it's not about sides. It's about the journey. > > 1. I believe that it is dishonest to impose stylistic restrictions on > > use of computer languages > > And dishonest can be good if it keeps 90% of bad programmers in line > 80% of the time, because good programmers would figure out the right > way themselves anyway. There you go again, wanting to stop people doing stuff. Let them go! Free the programmer! > > 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 > > Until, of course, you have one of these guys trying to fix your > application. And they're so stupid they can't read my code? It's just not true. And even if was I don't want to believe in a world like that. > > 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. > > Hmmm. Care to write a paper about it? I will when it's done. You'll be hearing a lot more about Thin on the new forum. Nic ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/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/