D.1 Architectural Antipatterns

Excessive Layering

Mistake

Unnecessary layers make application inefficient and bloated.

Watch for It When

Adding 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.

Solution

Understand 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.

Leak Collection

Mistake

Objects 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 When

Using objects with mismatched lifespans (usually collections), using objects that use collections internally, such as listeners, and using caches.

Solution

Put 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.



J2EE Design Patterns
J2EE Design Patterns
ISBN: 0596004273
EAN: 2147483647
Year: 2006
Pages: 113

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net