Thursday, May 5, 2011

Should Exceptions be placed in a separate package?

I am taking on a project where all the Exceptions have been placed in a separate package com.myco.myproj.exceptions.

Is this good practice?

From stackoverflow
  • I would expect the exceptions for a package to exist within that package. e.g.

    com.oopsconsultancy.models.pricing
    

    would contain pricing models and related exceptions. Anything else seems a bit counter-intuitive.

    S.Lott : +1: Exception is co-located with the things that cause the Exception.
  • It is a bad practice.

    It is a coincidental grouping. Packages should be coherent. Don't group exceptions, interfaces, enum, abstract classes, etc., into their own package. Group related concepts instead.

0 comments:

Post a Comment