[bind10-dev] Exceptions - nested vs on top of header

Michal 'vorner' Vaner michal.vaner at nic.cz
Mon Dec 27 16:43:41 UTC 2010


Hello

There seems to be slight disagreement during review of #447. I tend to define
new exceptions as nested classes of whatever throws them. I have some motivation
to do so (see below), but the rest of code doesn't seem to use that much.
Hangfeng thinks it is a problem to differ from the rest of the code and that I
should use toplevel class on top of the header file, because it is what the rest
of the software does.

The reasons I have are:
• There can be the same error condition thrown from different classes. If we
  want to distinguish, I think it is better to have SomeClass::BadSituation and
  OtherClass::BadSituation (and both of them write throw BadSituation), than
  SomeClassBadSituation and OtherClassBadSituation. And having such a long names
  seems like bat OOP practise.
• With doxygen, two classes in the same header file won't end up on the same
  page. But if it is nested class, it will be listed on the enclosing class's
  documentation, therefore listing all the exceptions related to it at one
  place (usually, noone needs to click on the exception class itself, what it
  does is usually clear from its name). And I think people look into
  documentation more often than into the source code (I look into the code only
  once the documentation is unclear).

So, what the others think? Should we have a rule about which should be used? Or
is it OK if everyone uses what feels better for him?

Thank you

-- 
2 keys should be enough for everyone

Michal 'vorner' Vaner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/bind10-dev/attachments/20101227/28d303d5/attachment.bin>


More information about the bind10-dev mailing list