On 9 June 2010 11:59, Bec Carter <[email protected]> wrote:

> eg. I have a class which generates reports. Part of the process is to
> create a directory if it does not already exist. If the create
> directory  fails several types of exceptions can be thrown like
> System.UnauthorizedAccessException, DirectoryNotFoundException and so
> on. Should the caller of this class care about all of these or should
> they just worry about catching a ReportGenerationException which tells
> them exactly what went wrong?
>

In the interests of lower module coupling & abstraction, I would always
choose the latter. The fact that you need to create directories to do
whatever is (well, should be I would think) pretty irrelevant to the caller
(which might be an ASPX or something that wants to show the report to the
end user).

In the future you might choose to rewrite your class to work off a DB, cloud
storage, or something else.

-- 
David Connors ([email protected])
Software Engineer
Codify Pty Ltd - www.codify.com
Phone: +61 (7) 3210 6268 | Facsimile: +61 (7) 3210 6269 | Mobile: +61 417
189 363
V-Card: https://www.codify.com/cards/davidconnors
Address Info: https://www.codify.com/contact

Reply via email to