Chapter 11: Anti-Patterns Flashcards
What is refactoring?
A refactoring is a correctness-preserving transformation that improves quality of the system
Are anti-patterns refactored?
True, they are refactored to overcome their negative consquences.
What are the state of affairs?
- One of six software projects are unsuccessful
- One third of software projects are cancelled
- Delivered system the budget and time to deliver is double as expected
What is the God Class anti-pattern?
There is one god class that performs most of the work of the system while all other classes provide a very small role
What is the problem with God Class?
Causes excessive message traffic
Solution to the God Class?
Refactor the design to uniformly distribute intelligence to top-level classes in the system.
Locality principle.
What is the Excessive Dynamic Allocation anti-pattern?
Excessive dynamic collection addresses frequent unnecessary creation and destruction of objects in the same class
What is the problem with excessive dynamic allocation?
The time it takes to initialize the dynamic object on the heap and delete it off the heap ruins performance
What is the solution to the excessive dynamic allocation?
Pre-allocate a “pool” of objects that are used frequently and store them in a collection or share objects.
Application of the processing vs frequency principle.
What is the Circuitous Treasure Hunt?
Software retrieves data from a first table, uses those results to search a second table, retrieves data from the table and so on, until the “ultimate results” are obtained
What is the problem with Circuitous Treasure Hunt?
Impact on performance is the large amount of data processing required to do the ultimate search.
Especially when figuring out the last call to make in the search.
What is the solution to the Circuitous Treasure Hunt?
Select a different data organization if a database access problem occurs early in development
In distributed systems use adapter pattern to allow for a more reasonable interface for remote calls
What is the adapter design pattern?
Adapters are used to enable objects with different interfaces to communicate with one another.
What is the one-lane bridge anti-pattern?
One, or only very few processes are allowed to execute concurrently
What is the problem with one-lane bridge anti-pattern?
All other processes must wait while other processes run.
Solution to the one-lane bridge anti-pattern?
Allow for more resources to be shared for that more processes are allowed to run concurrently.
Follows the shared resource principle.
What is the traffic jam principle?
The performance impact of the traffic jam is the transient behavior that produces wide variability in response time
What is the problem with the traffic jam principle?
One-lane bridge produces many processes waiting for a turn which then means it takes time for the service to get back to normal
What is the solution to the traffic jam principle?
If problem is caused by one-lane bridge then solving that pattern will help
If problem is caused by periodic high demand then use the spread-the-load principle.