| «« Images in Hotmail Junk Mail | Hackers and Painters »» |
|
About
I'm Ryan Lowe, a Software Engineering graduate living in Ottawa, Canada. I like agile software development and Ruby on Rails.
I write this blog in Canadian English and don't use a spell checker. Typos happen.
Projects
» Full-time Ruby on Rails freelancer
» Full-time with Rails since May 2005 » Former committer for RadRails (now Aptana) » I also have a few Rails side-projects in development: 1. wheretogoinTO.com Toronto nightlife 2. Hey Heads Up! TODO list and sharing 3. Layered Genealogy family history research 4. foos for foosball scoring 5. fanconcert for music fans (on hold) Hiring Rails developers? I can telecommute by the hour from Ottawa, Canada »» Email: rails AT ryanlowe DOT ca
BulletBlog
Now hosted on Hey! Heads Up -- check it out!
Syndication
Pings
Recent
Derek Lowe's (Ryan's older brother) words at Ryan's funeral
blog@ryanlowe.ca no more Forging Email Headers: Good, Bad or Ugly? Sarcastic Dictionary (Part 1 of Many) Tags Hierarchies Twisting Rails is Risky Business Risky Business? My Take on Early Alphas Whoa, it's August 2007 Closing Comments A Postscript to "Growth at the grassroots" »» All Blog Posts
Linkage
del.icio.us/ryanlowe
technorati/ryanlowe.ca/blog Aurora Roy Jim Andrew Trasker Travis Kibbee Karen Dr. Unk Ayana Van Bloggers Joel Spolsky Robert Scoble Tim Bray Dave Winer Raymond Chen James Robertson Ruby/Rails Bloggers rubyonrails.org weblog David Heinemeier Hansson Dave Thomas James Duncan Davidson Mike Clark Jamis Buck Signal vs. Noise Tobias Luetke Amy Hoy: (24)slash7 Jeremy Voorhis Eclipse Bloggers Planet Eclipse EclipseZone Luis de la Rosa Eclipse Foundation Kim Horne Billy Biggs Ian Skerrett Mike Milinkovich Bjorn Freeman-Benson Denis Roy
Archives
|
UnsupportedOperationException
If you are using an agile-type methodology to implement a Java interface you won't be able to implement all of the required methods at once. But the compiler will complain if you don't have the functions there, so you need stubs. Eclipse leaves nice stubs with TODO comments but the functions return default values (ie. null, 0). On Jim's Comments: An exception won't be thrown unless you use the unimplemented method. Having your program crap out is exactly what you want to do. Now if you put code in the stub to simulate functionality then you'd take the exception out, obviously. But when it's completely unimplemented, you need to know that. Using it is a programming error and that's exactly what runtime exceptions are for. As well, you can't "pay attention to the TODOs" if you are using a class like a black box or abstraction, which is the whole point of OOP. Posted at May 08, 2003 at 08:47 PM ESTLast updated May 08, 2003 at 08:47 PM EST Comments
ummm, I don't like that at all. If you are building something like that, that means that you cannot call the stub methods. You just have them in so that it compiles. If you actually hit them your program will crap out. If you wanted your stub methods to kill the app, I guess you could do a System.exit(0) instead. If you have them returning dummy values, yes, they might go un-noticed if you don't see the todo's, but at least you could test and play with your program. I think that if you pay attention to the todo's, what they have is fine. If you are building something with a gui, maybe you would want to do a printout message to the console so that you can be reminded of the stubb... I just don't agree with throwing that exception. » Posted by: JimboJones at May 8, 2003 09:52 PMI would have to say that both should be used depending on the problem you're solving. On one hand, when using exceptions, you are better able to see the flow and dependancy of your methods. This bodes well for solving problems that have many decision points. However, you can also argue that sometimes you just want to see where you are at in the big picture. That's when it's good just to have your stub print something to the console to remind you harmelessly, but not break the program. Either one depends on the problem although I believe returning 0, instead of printing something *and* returning 0, is no good. You have to have something to remind you of your incomplete work during compile and runtime, equally. » Posted by: roy at May 10, 2003 04:30 AMthe unsupported thing is excellent, i use it all the time, the main issue i take with jimbo's comments is that returning dummy values you have to 'pay attention to the todo's'", whereas using the exceptions... the system pays attention for you (also not ryan's comments... just because you throw exceptions does not mean that the code using your stuff has to try/catch it) » Posted by: andrew at May 11, 2003 02:27 PM |