Re: Poor Man's Genericity?



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

.



Relevant Pages

  • Re: AES and Diehard
    ... >you could employ kill file, ... The result of encryption which might eventually develop ... a standard for crypto the 'diversity' of interests is ... compression algorithm could exploit in order to compress. ...
    (sci.crypt)
  • [HPADM] SUMMARY: File Transfer from AS400 to HP-UX with compression and e ncryption?
    ... Also I'd like to know what compression and/or encryption techniques might be ... We're currently doing FTP from AS400 which is taking about 5 hours so they'd ... The gzip site says there is no encryption available for gzip so one would ...
    (HP-UX-Admin)
  • Re: Compression and encryption
    ... I would like to have both encryption (in case the computer gets ... I could tell Windows to compress the files that get written to the ... Windows XP Pro comes with EFS. ... I want both compression and encryption. ...
    (microsoft.public.windowsxp.general)
  • Re: Just a thought...
    ... idea apply bijective arithmetic compression or bijective PPM compression ... like in BICOM before the encryption. ... way even if the correct key was used say for a CBC AES type of encryption ... you could rotate the file using DSC or you could add a secret number ...
    (sci.crypt)
  • Re: Logical Thinking...???
    ... Aside from the fact that it's mighty hard to define "random noise," ... even over a set of common compression methods. ... (to the compressed file + its encryption key ...
    (comp.sys.hp48)