What’s New for Today

  1. Effective Java
    • exception
      • use exceptions only for exceptional conditions
        • not use in ordinary control flows
        • state-dependent, state-test methods
        • optional
      • use checked exceptions for recoverable, unchecked exceptions for other cases
      • avoid unnecessary use of checked exception
        • checked exceptions mandate programmers to catch errors –> pros and cons but it clutters the program
        • dependency issue –> service - repository service has to catch technical errors
      • favor use of standard exceptions
        • most of exceptions are already implemented
        • easy to use, maintain
      • throw exceptions appropriate to abstraction
        • higher classes can’t predict lower classes’ exception –> due to inheritance
        • transfer it to higher exception case
        • consider using exception chaining
      • document all exceptions
      • include failure-capture informations
        • error information must contain all of the parameters related to exception
      • strive for failure-atomicity
        • even though the method end successfully, the state must be consistent before and after the method execution
        • use copy of input paramters rather directly using them
        • check parameter before method execution
      • don’t ignore exceptions
        • unhandled exceptions can slowly make the program dead

태그:

카테고리:

업데이트:

댓글남기기