Overview
You can classify anti-pattern in different categories. They do not only exist for software development but also e.g. for project management. Because PatternTesting is a framework for developer we look only at those anti-pattern where PatternTesting can help you. But we will also take a look into other detectors which are common in many Java projects and helps you to find such code smells.
- Design Anti-Pattern
- These are architecturally anti-pattern where PatternTesting cannot do much for you. This is mainly the operation area of code metrics tool like jdepend or Sonar/ comes in.
- Code Smells
- PatternTesting is a framework which helps you to write better code. This chapter lists some antipattern which are recognized by PatternTesting or where PatternTesting helps you to avoid them.
- Methodological
- These are anti-pattern like copy-and-paste programming which happens often if you have lazy or unexperienced programmers.
For a detailed description of the antipatterns follow the link in the tables.
Design Anti-Pattern
Anti-Pattern |
Short Description |
Detectors |
Spaghetti Code |
compact code with missing structures, hard to read |
JDepend, Sonar, ... |
Code Smells
Exception Handling
Logging and Debugging
Others
Anti-Pattern |
Short Description |
Detectors |
Broken Initialization (NoClassDefFoundError) |
instantiation of class fails during initialization |
patterntesting-rt |
Faulty Default Generation |
generated code is wrong |
patterntesting-rt |
Lava Flow |
also known as Dead Code |
patterntesting-rt |
[Not Yet Implemented] |
implementation of a method is not yet finished |
patterntesting-rt |
[incorrect equals() and hashCode()] |
the hashCode contract was violated, equals() and hashCode() should only rely on the internal state of an object and other errors |
patterntesting-rt, FindBugs |
[Untested Serializable] |
the class implements Serializable but there is no test to verify it |
patterntesting-rt, FindBugs, PMD |
Transient Trap |
there are some traps if you define transient attributes |
patterntesting-check-ct, FindBugs |
Null Flag |
null values are used as flags for exceptional conditions |
patterntesting-check-rt |
[System.out-Logging] |
logging is done using System.out or System.err |
patterntesting-check-ct, PMD |
[Undefined Encoding] |
the encoding is not defined and depends on the used OS or environment |
patterntesting-check-ct, FindBugs, |
[Underscores] |
don't use underscores in Java names |
patterntesting-check-ct |
Methodological
Detectors
Not only PatternTesting can detect code smells. There are other tools available which does static code analysis to find possible errors:
The strength of PatternTesting is the support of dynamic code analysis. To do that there are several sub projects:
- PatternTesting Runtime (patterntesting-rt)
- PatternTesting Check-Runtime (patterntesting-check-rt)
- PatternTesting Check-Compile-Time (patterntesting-check-ct)
- PatternTesting Exception (patterntesting-exception)