Re: Poor Man's Genericity?
- From: "megagurka" <megagurka@xxxxxxxxx>
- Date: 23 Nov 2005 05:31:38 -0800
Chris Uppal skrev:
> megagurka wrote:
>
> > If you write a function that encrypts a file, you obviously declare
> > that the function can throw a file error exception. What's wrong with
> > that?
>
> At a later date you decide that it would be better to compress the file before
> encryption (which it often is, provided you strip off any compression headers).
> So you add in a compression step. But that can throw errors too.
This is a very contrieved (and badly designed) example, you typically
don't add totally unrelated functionality to an existing function, you
would create a new function that performs compression and encryption.
Besides, a compression algorithm shouldn't usually throw checked
exceptions because it's usually not dependent on an external device, it
will work the same every time given the same input parameters.
> If you had thought of it early enough, you could have declared your encryption
> routine to throw a (checked) custom error (not a file error) which /contained/
> another error. In the early version of the code that would always have been a
> file error, in the later version it could also be an encryption error. OK,
> fine, that works and is pretty flexible. But then you end up creating hosts of
> custom error types for every operation that could conceivably have an error
> mode either in its current implementation /or in any future version/.
Of course, if you want forward compatibility you have to design for it.
But this is not unique for checked exceptions, the same applies to
parameters and return values. They are all part of the method
signature.
/JN
.
- References:
- Poor Man's Genericity?
- From: gbmvdd
- Re: Poor Man's Genericity?
- From: Benji
- Re: Poor Man's Genericity?
- From: pkriens
- Re: Poor Man's Genericity?
- From: megagurka
- Re: Poor Man's Genericity?
- From: Chris Uppal
- Poor Man's Genericity?
- Prev by Date: Re: addKeyListener in JInternalFrame?
- Next by Date: Re: servlet problems with session attributes
- Previous by thread: Re: Poor Man's Genericity?
- Next by thread: Re: Poor Man's Genericity?
- Index(es):
Relevant Pages
|