Recent Posts
Archives

Posts Tagged ‘IDEA’

PostHeaderIcon Default method on interface implementing

Abstract:

Developpers happen to forget to implement concrete classes on creating new implementations. Indeed, IDEs fill methods content with canonical return values, (null for object, 0 for numerics, etc.). Consequently, errors appear only on deployment stage, when it is not on running.

To avoid this, here is the tip I use: raising a default exception. If unit tests are generated, then the exception is raised on development stage, which is better than after one hour compiling / deployment / execution ;-).

Process:

On IntelliJ IDEA, open:

  • Project Settings
    • File Templates
      • Code
        • Implemented Method Body
        • write: throw new UnsupportedOperationException("Class Name : ${CLASS_NAME} - Method Name : ${METHOD_NAME}");