| D.1 Architectural Antipatterns
 MistakeUnnecessary
layers make application inefficient and bloated. Watch for It WhenAdding layers to any application, developing a
small application that does not need to scale, or building adaptors
to external programs that duplicate functionality of the external
program. SolutionUnderstand the costs and benefits of each layer in the system. Layers
generally have a benefit in terms of either extensibility (providing
a reusable interface) or scalability (caching data). Match the use of layers to the general application type. For example,
do not build a complex, multilayered business tier for a small
application that simply accesses a local database. 
 MistakeObjects with a short lifespan cannot be garbage-collected because an
object with a long lifespan refers to them, resulting in a memory
leak. Watch for It WhenUsing objects with mismatched lifespans (usually collections), using
objects that use collections internally, such as listeners, and using
caches. SolutionPut adds and removes close to each other in the code. If you have a
cache, define an expiration policy. Where possible, use weak
references to allow garbage collection. |