anti patterns siddhesh lecture1 of3
DESCRIPTION
Anti Patterns - what not to do!TRANSCRIPT
![Page 1: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/1.jpg)
Anti-PatternsRefactoring Software, Architectures and Projects in Crisis
Siddhesh Bhobe8-Aug-2002
![Page 2: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/2.jpg)
Menu Definition Motivation for AntiPatterns Software Development AntiPatternsIn Part II: Software Architecture AntiPatterns In Part III: Software Project Management
AntiPatterns
![Page 3: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/3.jpg)
Pattern… Arrangement of repeated parts Design or shape to direct the
cutting of cloth Model or specimen
But a pattern can also be one of behavior!
![Page 4: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/4.jpg)
AntiPattern… Tells you what to avoid Identification of what to avoid is a
critical factor in successful software development
AntiPatterns rampant in Software Development Architecture Management Behavior
![Page 5: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/5.jpg)
Occur as a result of… Manager or developer not knowing
better Insufficient knowledge or
experience in solving a particular type of problem
Applying a perfectly good pattern in wrong context
![Page 6: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/6.jpg)
![Page 7: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/7.jpg)
“An AntiPattern is a literary form that describes a commonly occurring solution to a problem that generates decidedly negative consequences”
![Page 8: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/8.jpg)
Questions How can I recognize the most
common software design mistakes? What can we do to fix bad software? How can we get our design process
on track? How do I know when I am being
misled by a vendor?
![Page 9: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/9.jpg)
More Questions Is the latest standard or
technology breakthrough going to solve my problems?
Is our project headed for disaster? What are the “gotchas” of software
reuse?
![Page 10: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/10.jpg)
Software Development AntiPatterns
![Page 11: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/11.jpg)
AP: The Blob
“This is the class that is really the heart of our architecture”
![Page 12: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/12.jpg)
Symptoms and Consequences Procedural-style design One object with lion’s share of
responsibility Others hold data or execute simple
processes Lack of cohesiveness Too complex for reuse and testing
![Page 13: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/13.jpg)
Typical Causes Lack of architecture skills Prototypes developing into
production systems Defining system architecture as
part of requirements analysis
![Page 14: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/14.jpg)
Known Exceptions Wrapping legacy systems Just make the system accessible
![Page 15: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/15.jpg)
Solution Identify functionalities according to
“contracts” Find “natural homes” for these
collections of functionalities Remove redundant associations Top Down Approach: Migrate some
functionalities to the data classes
![Page 16: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/16.jpg)
AP: Lava Flow
“Oh that! Well Ray and Emily wrote that routine back when Jim was trying a workaround for Irene’s input processing code. I don’t think it’s used anywhere now, but I am not sure. It isn’t really documented clearly, so just leave it alone”
![Page 17: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/17.jpg)
Symptoms and Consequences Frequent unjustifiable variables
and code fragments Loose, “evolving” architecture Dead code or commented out
blocks
![Page 18: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/18.jpg)
Typical Causes R&D code placed into production Uncontrolled distribution of
unfinished code Single developer written code Lack of configuration management Transient development teams Hasty changes on the fly
![Page 19: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/19.jpg)
Known Exceptions Small-scale prototypes in R&D
environments Deliver rapidly and results not
required to be sustainable
![Page 20: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/20.jpg)
Solution Ensure that sound architecture
precedes code development Configuration Management Curing existing problem is often
very painful
![Page 21: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/21.jpg)
AP: Functional Decomposition
“This is our ‘main’ routine, here in the class called LISTENER”
![Page 22: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/22.jpg)
Symptoms and Consequences Resembles procedural language in
class structure Classes with names like
“Calculate_Interest” is a sure indication
Classes with all private variables No inheritance Can result in incredibly complex code
![Page 23: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/23.jpg)
Typical Causes Output of experienced non-object
oriented programmers who design an implement an OO application
![Page 24: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/24.jpg)
Known Exceptions Fine when OO solution is not
required, and only required to give an OO interface to the implementation code
![Page 25: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/25.jpg)
Solution Define analysis model to explain the
critical features of the system Formulate design model that
incorporates essential pieces Combine several classes that satisfy
a single design objective (Helper classes).
Rewrite classes with no state as function
![Page 26: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/26.jpg)
AP: Poltergeists: Restless Ghosts
“I am not really sure what this class does, but it sure is important!”
![Page 27: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/27.jpg)
Symptoms and Consequences Temporary, short duration objects Redundant navigation paths Transient associations Single-operation classes that “seed”
other classes Classes with “control-like” operation
names like “start_process_alpha”
![Page 28: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/28.jpg)
Typical Causes Bad architecture or design Wrong tool for the job Architectural commitments during
requirements analysis
![Page 29: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/29.jpg)
Known Exceptions No exceptions
![Page 30: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/30.jpg)
Solution Remove these classes from the
hierarchy Add functionality in the related
classes they invoked
![Page 31: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/31.jpg)
AP: Boat Anchor Piece of hardware or software that
serves no useful purpose on the current project
![Page 32: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/32.jpg)
Typical Causes Policy or programmatic
relationship Starting assumption or constraint
in a project Commitment to product without
technical evaluation
![Page 33: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/33.jpg)
Solution Keep technical backups during
evaluation phase Prototype with evaluation licenses Rational decision making prior to
acquisition
![Page 34: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/34.jpg)
AP: Golden Hammer
“Maybe we shouldn’t have used Excel macros for this job after all”
![Page 35: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/35.jpg)
Symptoms and Consequences Identical tools and products used for
wide array of conceptually diverse requirements
Inferior performance and scalability Developers debate requirements
with analysts and end users Existing products dictate design and
architecture
![Page 36: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/36.jpg)
Typical Causes Familiar technology or concept
applied obsessively to many problems
Large investments made in training in a particular technology or product
Reliance on proprietary features
![Page 37: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/37.jpg)
Known Exceptions If the product that defines the
constraint is the intended strategic solution for long term
Product is part of a vendor suite that provides for most of the software needs.
![Page 38: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/38.jpg)
Solution Commitment to alternative
technologies and approaches Hiring people with diverse
backgrounds and experiences Exposure of developers to
technical developments
![Page 39: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/39.jpg)
AP: Dead End Modified reusable component no
longer supported or maintained by the supplier
Shifts burden to the developer and maintainers
Upgrades cannot be easily integrated Support problems get blamed on
modifications
![Page 40: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/40.jpg)
Known Exceptions Testbeds that support basic
research such as throwaway code Significant benefits through
customization
![Page 41: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/41.jpg)
Solution Avoid COTS Customization and
modifications to reusable software Use mainstream platforms and
upgrade in sync with vendor Use isolation layers
![Page 42: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/42.jpg)
AP: Spaghetti Code
“It’s easier to rewrite this code than attempt to modify it”
![Page 43: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/43.jpg)
Symptoms and Consequences Very low reuse value Flow dictated by object
implementation, not by clients Minimal relationships between
objects Difficult to maintain and extend
![Page 44: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/44.jpg)
Typical Causes Inexperience Ineffective code reviews No design prior to implementation Developers working in isolation
![Page 45: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/45.jpg)
Known Exceptions Reasonably acceptable if
interfaces are coherent Lifetime of the code is short Product developed to obtain
domain knowledge for designing products with an improved architecture later on
![Page 46: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/46.jpg)
Solution Code cleanup Term doesn’t appeal to managers,
so call it “software investment” Code cleanup should follow each
addition of feature Performance improvement is also
part of code cleanup
![Page 47: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/47.jpg)
Examples of code cleanup Write accessor functions for use in
refactored code Convert code segments into
functions for reuse Reorder function arguments for
consistency Remove inaccessible or dead code Rename classes, functions, variables
![Page 48: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/48.jpg)
AP: Input Kludge “End users can break new
programs within moments of touching the keyboard”
Use of ad hoc algorithms for handling program input
Solution: Use production-quality input algorithms like lexical analysis and parsing software
![Page 49: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/49.jpg)
AP: Cut-and-Paste Programming
“Man, you guys work fast. Over 400,000 lines of code in three weeks is outstanding progress!”
“Hey, I thought you fixed that bug already, so why is it doing this again?”
![Page 50: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/50.jpg)
Symptoms and Consequences Similar segments of code all over
the code base Duplication of testing, review, bug
fixing efforts
May have positive short-term consequences increased like line count
![Page 51: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/51.jpg)
Typical Causes Degenerate form of software reuse:
Reusing source code Inexperienced programmers
following examples of other senior programmers
Taking working examples and modifying them
Organization rewards development speed, not reuse and overall design
![Page 52: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/52.jpg)
Known Exceptions When the sole aim is to get the
code out of the door as quickly as possible
However, price paid is one of increased maintenance
![Page 53: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/53.jpg)
Solution Black box reuse
![Page 54: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/54.jpg)
In Part II and III… Software Architecture AntiPatterns Software Project Management
AntiPatterns
![Page 55: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/55.jpg)
References AntiPatterns: William Brown,
Raphael Malveau et al (PSPL Library S-76)
http://www.antipatterns.com/thebook.htm
Similar presentation at http://www.mitre.org/support/swee/html/67_mccormick
![Page 56: Anti Patterns Siddhesh Lecture1 Of3](https://reader036.vdocuments.net/reader036/viewer/2022062512/55491e32b4c90547498b7794/html5/thumbnails/56.jpg)
Thank You!