From: Rhino on 25 Mar 2010 15:04 Lew <lew(a)lewscanon.com> wrote in news:8397e69a-955a-4ec1-add4-c9f40b567b1f(a)e7g2000yqf.googlegroups.com: > Lew wrote >>> (Please trim your posts.) >> > > Rhino wrote: >> Actually, I would but in other threads people have said they're >> leaving theirs intact for the benefit of those using Google groups. >> Won't I be preventing Google Groups users from benefitting from this >> discussion if I trim my posts? >> > > No, quite the contrary. And so what if you did? > Surely one of the benefits of newsgroups is that they allow other people to look at archived questions and learn from them. If the archived materials are severely trimmed, that could make it much harder to learn from. > Rhino wrote: >> As I mentioned in the original post, the year 0 never happened - the >> calendar went straight from the year 1 BC to 1 AD. Therefore, if >> someone put "0" (or "00" or "000" or "0000") in a form that asked for >> a year, they'd be inputting an invalid year. � >> > > The year 1 never happened either. Neither did the year 100. Are you > going to reject those years, too? > Again, I don't particularly want to dwell on the year 0 here. I introduced this merely as an example of something that might be a candidate for a checked exception. I don't claim to be a guru on the history of time but I am interested in history, although mostly contemporary history rather than the Roman era. If the year 0 did exist and the years 1 and 100 didn't, this is the first I'm hearing of it. No history course I ever took at high school or university suggested any such thing. The teachers I had talked about B.C. and A.D. and said that 1 A.D followed 1 B.C. and that there was no year 0. Umpteen timelines all followed that same model. [Now, I recognize that a lot of this is "retroactive" in the sense that the Romans didn't start distinguishing between B.C and A.D in the year I would call 1 A.D. Western historians started doing that well after the fact. Perhaps that's what you mean when you say the year 0 did exist and the years 1 and 100 did not??] > Note, again, that the standard Java API does accept the year 0, > because it uses the proleptic Gregorian calendar. > > Are you going to reject October 10, 1582? That only happened some > places. Are you going to consider February 28, 1560, to be in the > same year as October 28, 1560? That would be wrong. Do you consider > that Cervantes and Shakespeare died on the same day because they died > on the same date, even though they died ten days apart? > > Lew wrote: >>> Just out of curiosity: >>> - Why not just use 'GregorianCalendar#isLeapYear(int year)'? �FWIW, >>> that method takes 0 as a legitimate argument, signifying BC 1. >> > > Rhino wrote: >> Huh? Interpreting 0 as BC 1 makes no sense to me. >> > > That's because you haven't studied calendars very much, and apparently > haven't bothered to read the Javadocs very much either. > For pity sake, I DID read the Javadocs, although I didn't necessarily understand everything I saw. I am now going to assume that I've said that enough times that I don't need to say it again. > Lew wrote: >>> - Are you going to reject dates prior to 1582 in the Catholic world, >>> 1700 in Scandinavia, 1753 in Sweden or 1752 in the former British >>> Empire? >> > > Rhino wrote: >> Who said anything about rejecting those dates? >> > > Well, they didn't happen in the Gregorian calendar. Why wouldn't you > reject them? > I am not clear on what a Gregorian calendar does with dates before the establishment of the Gregorian calendar in 1582 (for the Catholic countries and later for other countries.) I am not trying to become an expert in the history of timekeeping. I'm trying to ask a question about checked and unchecked exceptions. The example that I thought would represent a simple illustration of a validation in a method has obviously backfired on me. So let me just contruct a new example that will, I hope, be less controversial so that I can actually confirm my understanding of exceptions. > And am I not permitted to introduce a new concept, or must everything > I suggest have been brought up already before I comment? > I said nothing of the kind. I don't know where you are getting that. > Lew wrote: >>> - Are you aware that New Year's Day was on March 25 prior to the >>> adoption of the Gregorian calendar? �(You would be if you read >>> Javadocs.) >> > > Rhino wrote: >> Yes, actually I did know that. And I have read Javadocs. � >> > > Then you already knew about the proleptic Gregorian calendar and that > the Java 'GregorianCalendar' accepts year 0. > > Rhino wrote: >>>> 2. This situation is recoverable since the user could easily >>>> correct this if it was brought to his attention. >> > > Lew wrote: >>> And therefore ...? >> > > Rhino wrote: >> I'm just trying to lay out my reasoning on the basis of what you and >> others have said on this subject to make sure I'm thinking this >> through correctly. >> > > Well, I pointed out that "recoverable" was not relevant, as it is far > too loose a concept that can apply to both checked and unchecked > exceptions, and therefore does not distinguish when to use one or the > other. > And that's why I tried to put the concept in somewhat more practical terms. > Lew wrote: >>> I don't see what being "recoverable" has to do with anything. �What >>> exactly do you mean by "recoverable" anyway? >> > > Rhino wrote: >> One of the criteria for whether to make something a checked or >> unchecked exception is whether an error is "recoverable", meaning >> (loosely) that >> > > No, it isn't. > >> there is some prospect that the error can be eliminated with a bit of >> human intervention. In this case, that human intervention would be >> displaying a message to the user saying that the year 0000 is not >> valid and please change it to a year that actually existed. >> > > That reasoning applies equally well to checked or unchecked > exceptions. > Then I am still not clear on when I would use a checked exception and when I would not. I do NOT want to open this Year 0 can of worms again so let's try something that will hopefully be less controversial. I have a method called getSeconds. Its job is simply to take a number of hours, minutes and seconds and convert that to seconds. Here is the code, minus the comments (for brevity): public int getSeconds(int hours, int minutes, int seconds) { if (hours < 0) { Object[] msgArgs = {new Integer(hours)}; msgFmt.applyPattern(locMsg.getString("msg032")); throw new IllegalArgumentException(msgFmt.format(msgArgs)); } if (minutes < 0) { Object[] msgArgs = {new Integer(minutes)}; msgFmt.applyPattern(locMsg.getString("msg033")); throw new IllegalArgumentException(msgFmt.format(msgArgs)); } if (seconds < 0) { Object[] msgArgs = {new Integer(seconds)}; msgFmt.applyPattern(locMsg.getString("msg034")); throw new IllegalArgumentException(msgFmt.format(msgArgs)); } return (hours * HoursMinutesSeconds.SECONDS_IN_ONE_HOUR) + (minutes * HoursMinutesSeconds.SECONDS_IN_ONE_MINUTE) + seconds; } Can we agree that it makes no sense to have negative hours, minutes and seconds and that if the calling program supplies negative numbers for any of those parameters, it is reasonable to notify the caller of this fact so that the caller can, perhaps, remedy the situation? Would we agree that this example illustrates a proper use of unchecked exceptions? > Rhino wrote: >>>> 3. IllegalArgumentException should be put in the throws clause of >>>> the message signature. >> > > Lew wrote: >>> No. �Bad idea. >> > > Rhino wrote: >> Why? >> > > As I have said a couple of times already in this thread, and surely > you have read, because it accomplishes nothing. It does not add to > the documentation, it does not become part of the method signature, it > does not require callers to catch the exception, and it's a waste of > time and effort. The 'throws' clause is designed for and only useful > with checked exceptions. > Okay, fine. > Instead, as you wrote: >>>> 4. The Javadoc @throws (or @exception) should list >>>> IllegalArgumentException. >> > > Rhino wrote: >> If GregorianCalendar is going to interpret the year 0 as the 1 BC >> without my telling it to, I'm not sure I want to use >> GregorianCalendar.... >> > > But that is correct behavior, by ISO standard 8601. You really need > to study up on calendars, particularly the Gregorian calendar. May I > suggest careful study of > <http://en.wikipedia.org/wiki/Gregorian_calendar> > particularly > <http://en.wikipedia.org/wiki/ > Gregorian_calendar#Proleptic_Gregorian_calendar> > ? > Agreed, my ignorance of calendars and ISO 8601 is overwhelming. I will remedy that ignorance when time permits. > Sometimes people, and APIs, do the right thing even if you don't tell > them to. Furthermore, it is not your job to tell the standard API > what to do, but the standard API's job to tell you what it actually > does. As long as it works as documented, then you have no legitimate > gripe. > > Rhino wrote: >> Anyway, the year 0 is not really important here. I'm just trying to >> construct an example of what I consider a "recoverable" (for want of >> a better word) error so that I can see if I am understanding the use >> of checked and unchecked exceptions yet. >> > > "Recoverable" is an awful, terrible, vague, useless, unworthy and > ridiculous criterion for choosing between the two. Instead, consider > either > - RuntimeException for programmer error, checked exception for > environmental error, or > - RuntimeException to let a caller slide without a 'catch' clause, > checked exception to force the 'catch'. > > Whatever criterion you use, it's going to be a matter of style. There > are entire APIs out there that refuse to throw checked exceptions by > dint of the API writers' philosophy, others that go hog-wild with > them. It's up to the API writer what they choose to impose. > Fair enough. -- Rhino
From: Lew on 25 Mar 2010 19:59 Lew wrote >>>> (Please trim your posts.) Rhino wrote: >>> Actually, I would but in other threads people have said they're >>> leaving theirs intact for the benefit of those using Google groups. >>> Won't I be preventing Google Groups users from benefitting from this >>> discussion if I trim my posts? Lew wrote >> No, quite the contrary. And so what if you did? Rhino wrote: > Surely one of the benefits of newsgroups is that they allow other people > to look at archived questions and learn from them. If the archived > materials are severely trimmed, that could make it much harder to learn > from. It's the opposite. If the posts are not trimmed, then a researcher has to wade through pages and pages of repeated information to get at the nugget they seek. And I don't suggest "severely" trimming the posts, I suggest *appropriately* trimming the posts. For example, in this post I focus on the issue of trimming posts. I include all the necessary context to make the conversation explicable, but trimmed the parts that would have been irrelevant to the subtopic. Now, reading this, ask yourself which is clearer. Is there anything missing from this post that leaves you lost and wondering what we're discussing? Is there anything extraneous that dilutes the focus? If there is, then I goofed and you should point it out so that I can correct my mistake. -- Lew
From: Arne Vajhøj on 25 Mar 2010 21:55 On 25-03-2010 09:42, Rhino wrote: > Lew<lew(a)lewscanon.com> wrote in > news:0376797b-72ab-422d-9985-af8f9585d9be(a)k13g2000yqe.googlegroups.com: >> (Please trim your posts.) > Actually, I would but in other threads people have said they're leaving > theirs intact for the benefit of those using Google groups. Won't I be > preventing Google Groups users from benefitting from this discussion if I > trim my posts? No. GG understands the thread concept and are able to put posts in their proper context. And BTW you should keep the minimal context in your post - just not everything. Arne
From: Arne Vajhøj on 25 Mar 2010 21:59 On 25-03-2010 13:44, Lew wrote: > Rhino wrote: >> As I mentioned in the original post, the year 0 never happened - the >> calendar went straight from the year 1 BC to 1 AD. Therefore, if someone >> put "0" (or "00" or "000" or "0000") in a form that asked for a year, >> they'd be inputting an invalid year. > > The year 1 never happened either. Neither did the year 100. Are you > going to reject those years, too? Of course it did. If you want to know what happened then look at: http://en.wikipedia.org/wiki/1 http://en.wikipedia.org/wiki/100 Just because the naming were invented later does not mean that something did not exist. Arne
From: RedGrittyBrick on 26 Mar 2010 10:34 On 25/03/2010 19:04, Rhino wrote: > Lew<lew(a)lewscanon.com> wrote in > news:8397e69a-955a-4ec1-add4-c9f40b567b1f(a)e7g2000yqf.googlegroups.com: > >> Lew wrote >>>> (Please trim your posts.) >>> >> >> Rhino wrote: >>> Actually, I would but in other threads people have said they're >>> leaving theirs intact for the benefit of those using Google groups. >>> Won't I be preventing Google Groups users from benefitting from this >>> discussion if I trim my posts? As Lew suggests, No - trimming doesn't prevent people easily being able to view the whole of any prior message (after all that's what the references in the headers are for). Google Groups users are not the only readers of this newsgroup. If message headers are anything to go by, the majority of people first read this newsgroup using something other than Google Groups. > Surely one of the benefits of newsgroups is that they allow other people > to look at archived questions and learn from them. If the archived > materials are severely trimmed, that could make it much harder to learn > from. If I need to I can look at the whole thread in Google's archives (or indeed several others) and see the whole thread. If the thread is comparatively recent I would prefer to view the thread in my NNTP client (Thunderbird). Speaking only for myself, I prefer to read a series of short messages with short selective quotations rather than a series of increasingly lengthy messages each of which repeats everything I've already read. Please reconsider. "If you are sending a reply to a message or a posting be sure you summarize the original at the top of the message, or include just enough text of the original to give a context. This will make sure readers understand when they start to read your response. Since NetNews, especially, is proliferated by distributing the postings from one host to another, it is possible to see a response to a message before seeing the original. Giving context helps everyone. But do not include the entire original! " http://www.faqs.org/rfcs/rfc1855.html -- RGB
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: [ANN] RefleX 0.4.0 released Next: web service behind firewall without DNS |