agile refactoring for making systems more adaptableagilcoop.org.br/files/agilerefactoring.pdf ·...
TRANSCRIPT
![Page 1: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/1.jpg)
Agile Refactoring for Making Systems More Adaptable
Joseph W. YoderJoseph W. YoderThe Refactory, Inc.
October 11, 2009
[email protected]://www.refactory.com
![Page 2: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/2.jpg)
The Refactory Principals
John Brant
Brian Foote
Ralph Johnson
Don Roberts
Joe Yoder
Slide Slide -- 22
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Refactory AffiliatesJoseph BerginFred Grossman
Bill Opdyke
![Page 3: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/3.jpg)
Short Instructor BioJoseph Yoder began working with software in the mid 1980’s, and has developed
robust systems for many companies and organizations with global impact. Heis a founder and principle of The Refactory, Inc., a company focused on soft-ware architecture, design, implementation, consulting and mentoring of all facets of software development. Joe is an international speaker and pattern author on software architecture, design, and implementation. Joseph special-izes in Object-Oriented Analysis and Design, C#, Java, Smalltalk, Patterns, Agile Methods, Adaptable Systems, Refactoring, Reuse, and Frameworks. He has mentored developers on many types of software applications
Slide Slide -- 33
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
many types of software applications.
Joseph Yoder is a longstanding member and vice-chair of the board of The Hillside Group, a group dedicated to improving the quality of software development. Joseph has chaired the Pattern Languages of Programming Conferences (PLoP), as well as given many tutorials and talks at conferences such as JAOO, QCon, OOPSLA and ECOOP. He is co-author of the Big Ball of Mud pattern, which illuminated many fallacies in the approach to software architecture.
Joseph Yoder currently resides in Urbana, Illinois. He teaches Agile Methods such as XP, Design Patterns, Object Design, Refactoring, and Testing in industrial settings and mentors developers on these concepts. Joseph currently oversees a team of developers who have constructed an order fulfillment system based on enterprise architecture using the .NET environment. His other recent work includes working in both the Java and .NET environments, and deploying Domain-Specific Languages for clients. Joe thinks software is still too hard to change. He wants to do something about this and believes that putting the ability to change software in the hands of the people with the knowledge to change it is a promising avenue to solve this problem.
![Page 4: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/4.jpg)
Agile Principles
Scrum, TDD, Refactoring, Regular Feedback, Testing, More Eyes, …
Good People! Face-To-Face conversation.
Slide Slide -- 44
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Continuous attention to technical excellence!
Motivated individuals with the environment and support they need. Retrospectives!
Allow Requirements to Change! Encourage Software Evolution as needed!
![Page 5: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/5.jpg)
Agile Encourages Changes
Very Little Upfront Design!
Piecemeal Growth! Small Iterations!
Late changes to the requirementsf h
Slide Slide -- 55
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
of the system!
Continuously Evolving the Architecture!
Adapting to Changes requires the code to change and Refactoring supports changes to the code in a “safe” way.
![Page 6: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/6.jpg)
Agile & Refactoring
A key part of Agile is to allow things to change and adapt as dictated by business needs!
T t th h R f t i i
Slide Slide -- 66
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
To support these changes, Refactoring is encouraged by most Agile practitioners.
Agile has helped Refactoring be accepted into the mainstream development process (even sometimes encouraged).
![Page 7: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/7.jpg)
Ground Breaking Work
Before there was Agile…
Started at the University Of Illinois
Slide Slide -- 77
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Bill Opdyke & Don Roberts PHD Thesis
Refactoring Browser by John Brant and Don Roberts (first commercial tool)
![Page 8: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/8.jpg)
Refactoring Definition
Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of
Slide Slide -- 88
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
the code, yet improves its internal structure…Martin Fowler, RefactoringImproving the Design of Existing Code; Addison Wesley , 1999
![Page 9: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/9.jpg)
What is Refactoring
Refactoring is a controlled technique for improving the design of an existing code base
Small behavior-preserving transformations,
•
Slide Slide -- 99
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
• Each of might be "too small to be worth doing“
• Cumulative effect of transformations is significant
• Small steps help reduce the risk of introducing errors
• Avoid having the system broken while you are carrying out the restructuring
• Gradually refactor a system over a period of time
![Page 10: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/10.jpg)
A Simple Refactoring
Object
Object
Create Empty Class
Slide Slide -- 1010
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Concrete1 Concrete2
Concrete1 Concrete2
NewAbstract
![Page 11: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/11.jpg)
A Complex Refactoring
Array
Matrix
MatrixRep
Slide Slide -- 1111
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Matrix
ArrayRep
rep
SparseRep IdentityRep
Adapted from Don Roberts, The Refactory, Inc.
![Page 12: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/12.jpg)
Refactoring Code Smells
A code smell is a hint that something has gone wrong somewhere in your code. Use the smell to track down the problem. KentBeck (with inspiration from the nose of Massimo Arnoldi) seems to have coined
Slide Slide -- 1212
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
the phrase in the "OnceAndOnlyOnce" page, where he also said that code "wants to be simple". Bad Smells in Code was an essay by KentBeck and MartinFowler, published as Chapter 3 of Refactoring Improving The Design Of ExistingCode.
----Wards Wiki
![Page 13: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/13.jpg)
Code Smells Review
Duplicate Code, Long Method, Large Class,
Long Parameter List, Divergent Change,
Shotgun Surgery, Feature Envy, Data Clumps
Primitive Obsession Switch Statements
Slide Slide -- 1313
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Primitive Obsession, Switch Statements
Parallel Inheritance, Lazy Class
Speculative Generality, Temporary Field
Message Chains, Middle Man
Inappropriate Intimacy, Incomplete Lib Classes
Data Class, Refused Bequest, Comments
![Page 14: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/14.jpg)
Comments
We are not against comments but…
If you see large methods that have
Slide Slide -- 1414
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
If you see large methods that have places where the code is commented, use Extract Method to pull that out to a comment
![Page 15: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/15.jpg)
Comments Examplevoid printOwing (double amount) {
printBanner();
//print details
System.out.println (name: “ + _name);
System.out.println (amount: “ + amount);
Slide Slide -- 1515
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
…}
void printOwing (double amount) {
printBanner();
printDetails();
…}
void printDetails (double amount) {
System.out.println (name: “ + _name);
System.out.println (amount: “ + amount);}
![Page 16: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/16.jpg)
Agile & Testing
Many Agile practices highly encourage Testing as one of their core practices.
Processes like XP support developers iti it t t (XU it )
Slide Slide -- 1616
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
writing many unit tests (XUnit ).
Test Driven Development (TDD) is usually considered a key principle of Agile.
Testing was a key principle of Refactoring before there was Agile.
![Page 17: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/17.jpg)
Prerequisites of Refactoring
Since you are changing the code base, it is IMPORTANT to validate with tests.
Slide Slide -- 1717
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
There are also a time to refactor and a time to wait.
Need both Unit Testing and Integrated Tests for making sure nothing breaks
![Page 18: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/18.jpg)
Deciding Whether A Refactoring is Safe
"A refactoring shouldn't break a program.”What does this mean?
A safe refactoring is behavior preserving.
It is important not to violate:
Slide Slide -- 1818
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
It is important not to violate:naming/ scoping rules.type rules.
"The program should perform the same after a refactoring as before.”
Satisfying timing constraints.
![Page 19: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/19.jpg)
Using Standard Tools
To be safe, must have tests
Should pass the tests beforeand after refactoring
Slide Slide -- 1919
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Commercial Testing Tools
Kent Beck’s Testing Framework(SUnit, JUnit, Nunit, …)
Take small steps, testing between each
Java and C# tools are getting better
![Page 20: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/20.jpg)
Catalogue of Refactorings
Composing Method
Moving Features
Organize Data
Slide Slide -- 2020
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Organize Data
Simplifying Conditionals
Simpler Method Calls
Generalization
From Fowlers Book
![Page 21: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/21.jpg)
Composing Method Catalogue
Extract Method, Inline Method,
Inline Temp, Replace Temp with Query,
Introduce Explaining Variable
Slide Slide -- 2121
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Introduce Explaining Variable,
Split Temporary Variable,
Remove Assignments to Parameters,
Replace Method with Method Object,
Substitute Algorithm
![Page 22: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/22.jpg)
Extract Method
void printOwing(double amount) {printBanner();
//print details
Slide Slide -- 2222
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
//print detailsSystem.out.println(“name:” + _name);System.out.println(“amount:” + _amount);
}
![Page 23: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/23.jpg)
Extract Method (2)
void printOwing (double amount) {printBanner();printDetails(amount);
}
Slide Slide -- 2323
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
}
void printDetails (double amount) {
System.out.println(“name:” + _name);System.out.println(“amount:” + _amount);
}
![Page 24: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/24.jpg)
Extract Method Mechanics
Create a new method and name it after the intention of the code to extract.
Copy the extracted code from the source to the new method.
Slide Slide -- 2424
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Scan the extracted code for references to any variables that are local to the source method.
See whether any temps are used only within extracted code.
Pass into target method as parameters local-scope variables that are read from the extracted code.
Replace the extracted code in the source method.
![Page 25: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/25.jpg)
Remove Method with Method ObjectClass Order …
double price() {
double primaryBasePrice;
double secondaryBasePrice;
double tertiaryBasePrice;
// long computation;
Slide Slide -- 2525
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
// long computation;
…}
Order
price()
PriceCalculator
primaryBasePrice
secondaryBasePrice
tertiaryBasePrice
compute()
1
return new PriceCalculator(this).compute()
![Page 26: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/26.jpg)
Remove Method toMethod Object Mechanics
Create a new class named after method.
Give the new class a final field for the object that hosted the original method.
Give the new class a constructor for the original bj t d h t
Slide Slide -- 2626
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
object and each parameter.
Give the new class a compute method.
Copy the body of original method to compute.
Compile.
Replace the old method with the one that creates the new object and calls compute.
![Page 27: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/27.jpg)
Simplifying Conditionals Catalogue
Decompose Conditional, Consolidate Conditional Expression, Consolidate Duplicate Conditional Fragments,
Slide Slide -- 2727
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Remove Control Flag, Replace Nested Conditionals with (Guard Clauses | Polymorphism), Introduce Null Object, Introduce Assertion
![Page 28: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/28.jpg)
Replace Conditional with Polymorphism
You have a conditional that chooses different behavior depending on the type of an object
Slide Slide -- 2828
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Move each leg of the conditional to an overriding method in a subclass. Make the original method abstract!
![Page 29: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/29.jpg)
Replace Conditional with Polymorphism
double getSpeed() {
switch (_type) {
case EUROPEAN:
return getBaseSpeed();
case AFRICAN:
return getBaseSpeed() – getLoadFactor() * number
Slide Slide -- 2929
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
return getBaseSpeed() getLoadFactor() _number ofCocunuts;
…} Bird
getSpeed
European
getSpeed
African
getSpeed
![Page 30: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/30.jpg)
Replace Polymorphism Mechanics
If the conditional is part of a larger statement, take apart the conditional and use Extract Method.
If necessary use Move Method to place
Slide Slide -- 3030
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
If necessary, use Move Method to place the conditional at the top of the inheritance hierarchy.
Create classes and copy the body of the leg of the conditional into the subclass.
Compile and Test…and continue on.
![Page 31: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/31.jpg)
To move a function to a different class, add an argument to refer to the original class of which it was a member and change all references to member variables to use the new argument.
If you are moving it to the class of one of the arguments, you can make the argument be the receiver.
Moving Code“Refactoring”
Slide Slide -- 3131
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
y g
Moving function f from class X to class B
class X {int f(A anA, B aB){
return (anA.size + size) / aB.size;} ...
class B {int f(A anA, X anX){
return (anA.size + anX.size) / size;} ...
![Page 32: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/32.jpg)
You can also pass in a parameter object which gives the algorithm all of the
l h ll
Car f(a, b, c){if this.x > a then
this.x = a+belse if this.x < a thenthis.y = a+b
elsethis.x = a+b }
Moving Code“Refactoring”
Slide Slide -- 3232
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
values that it will need.
Inner Classes can help by providing access to values that the algorithm may need.
Car FStrategy
f(CarPars Car){if this.x > a then
this.x = a+belse if this.x < a thenthis.y = a+b
elsethis.x = a+b }
CarParsa, b, cx, y
![Page 33: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/33.jpg)
Refactoring andDesign Patterns (1)
What varies Design Pattern
Algorithms Strategy, Visitor
Actions Command
Slide Slide -- 3333
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Actions Command
Implementations Bridge
Response to change Observer
![Page 34: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/34.jpg)
What varies Design Pattern
Interactions between objects Mediator
Object being created Factory Method, Abstract
Refactoring andDesign Patterns (2)
Slide Slide -- 3434
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Object being created Factory Method, Abstract
Factory, Prototype
Structure being created Builder
Traversal Algorithm Iterator
Object interfaces Adapter
Object behavior Decorator, State
![Page 35: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/35.jpg)
Refactoring Summary
We have seen the mechanics for some of the Refactorings.
Slide Slide -- 3535
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
When you find smelly code, you often apply Refactorings to clean your code.
Refactorings do often apply Design Patterns.
![Page 36: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/36.jpg)
Allowing Systems to AdaptRequirements change within
application’s domain.
Domain Experts know their domain best.
Business Rules are changing rapidly.
Slide Slide -- 3636
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
g g p y
Applications have to quickly adapt tonew business requirements.
Agile Development Welcomes Changes to the Requirements, even late in the development!
One way to Adapt is to just Refactor to new business requirements…though sometimes…
![Page 37: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/37.jpg)
Forces – Shearing Layers
Who (Business Person, Analyst, Developer)
What (Business Rule, Persistence Layer,…)
When (How often How fast)
Slide Slide -- 3737
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
When (How often, How fast)
There is a different rate of change on the system.
Foote & Yoder - Ball of Mud PLoPD4
![Page 38: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/38.jpg)
Newborn Screening Newborn Screening Refactoring ExampleRefactoring Example
Doctor, HealthProf.
Slide Slide -- 3838
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Mother, Infant
Hospital, Lab
Blood Specimen
![Page 39: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/39.jpg)
Medical Observation Medical Observation ––First ModelFirst Model
Observation Person
Measurement convertTo:
Trait traitValue Quantity
unit amount expressOnUnit:
*
Slide Slide -- 3939
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
What happens when a new observation is required?
PhysicalMeasure
Blood
expressOnUnit: expressOnUnits:
EyeColor
HairColor
Gender
Height
Weight
…
…
FeedingType
Hearing
Vision
![Page 40: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/40.jpg)
Observation Design Observation Design (1(1st st Refactoring)Refactoring)
Person
+address()+phone()+name()
Observation
+phenomenon()
-recordedDate : Date-observedDate : Date-duration : TimePeriod
ObservationType
-phenomenon : Symbol
* *1 1
Slide Slide -- 4040
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Measurement
+observationValue()
Trait
+observationValue()
Quantity
+expressOnUnit(aUnit : Unit)+expressOnUnits(unitCollection : Collection)
-unit : Unit-amount : Number
1 1
![Page 41: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/41.jpg)
Height: 3 feet
Observation DesignObservation DesignExample
Slide Slide -- 4141
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Name: John SmithMother: Sue SmithFather:Address:Phone:
Eyes Color: Blue
![Page 42: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/42.jpg)
Observation DesignObservation Design(instance diagram)
aPerson name <John Smith>obsCollection
aMeasurement type value
anObservationType #height
Slide Slide -- 4242
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
value
aQuantity value <3> unit <ft>
aTrait type value <blue>
anObservationType #eyeColor
![Page 43: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/43.jpg)
Composing ObservationsComposing Observations
Observations can be more complex
Cholesterol
C t HDL LDL
Slide Slide -- 4343
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Components: HDL, LDL
Blood Pressure
Components: Systolic, Diastolic
Vision
Components: Left Eye, Right Eye
![Page 44: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/44.jpg)
Composite Observation Design Composite Observation Design (2(2ndnd Refactoring)Refactoring)
Person
+address()+phone()+name()
Observation
-recordedDate : Date-observedDate : Date
ObservationType
-phenomenon : Symbol 1..n
Slide Slide -- 4444
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Composite Pattern (GOF)
+phenomenon()
-observedDate : Date-duration : TimePeriod
Measurement
+observationValue()
Trait
+observationValue()
-phenomenon : Symbol
Quantity
+expressOnUnit(aUnit : Unit)+expressOnUnits(unitCollection : Collection)
-unit : Unit-amount : Number
CompositeObservation
-observations : Collection
1..n
![Page 45: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/45.jpg)
Observation DesignObservation DesignExample
Height: 3 feet
Slide Slide -- 4545
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Name: John SmithMother: Sue SmithFather:Address:Phone:
Eyes Color: Blue
Blood Pressure: Systolic: 120 mmHg Diastolic: 80 mmHg
![Page 46: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/46.jpg)
Composite Observation DesignComposite Observation Design(instance diagram)
anObservType<#BloodPressure>
aCompObs
Slide Slide -- 4646
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
aMeasurement<120 mmHg>
anObserType<#SYSTOLIC>
anotherMeasurement<80 mmHg>
anObser-Type<#DIASTOLIC>
![Page 47: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/47.jpg)
Composite and Primitive Composite and Primitive Observation DesignObservation DesignWhat we know about John?
aPerson name <John Smith>obsCollection
Slide Slide -- 4747
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Height: 3 feet EyesColor: Blue
Diastolic: 80 mmHg
Systolic: 120 mmHg
BloodPressure: 120/80
![Page 48: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/48.jpg)
Validating ObservationsValidating Observations
Each Observation has its own setof legal values.
Baby’s Weight: [0 30] pounds
Slide Slide -- 4848
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Baby s Weight: [0 30] pounds
HepatitisB: {positive, negative}
Left/Right Vision: {normal, abnormal}
GUI can enforce legal valuesbut we want business rules in domain objects
![Page 49: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/49.jpg)
ObservationType
-phenomenon : Symbol-validator : Validator
Validator
Validating Observations Design Validating Observations Design (3(3rdrd Refactoring)Refactoring)
Slide Slide -- 4949
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
DiscreteValidator
-descriptorSet : Collection
NullValidator RangedValidator
-intervalSet : Collection-validUnit : Unit
![Page 50: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/50.jpg)
ObservationType type
Party
Observation recordedDate comments
Validator
DiscreteValidator descriptorSet
RangedValidator intervalSet validUnit
NullValidator
Overall Observation DesignOverall Observation Design
Slide Slide -- 5050
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Measurement value value value: convertTo:
Trait value value value:
Quantity
CompositeObservation values
Is everything an Observation?How does the model specify the structure of the Composite?What is the relationship between Trait and DiscreteValidator?
![Page 51: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/51.jpg)
ObservationType phenomenonType isValid: obsValue
Party
Validator validatorName isValid: obsValue
DiscreteValidator descriptorSet
RangedValidator intervalSet validUnit
PrimitiveObservationType
CompositeObservationType
NullValidator
Observation DesignObservation Design
Slide Slide -- 5151
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Party
Primitive Observation observationValue
CompositeObservation
Observation recordedDate comments isValid
Quantity unit quantity convertTo:
DiscreteValues
Current Design
![Page 52: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/52.jpg)
Observation DesignObservation Design
ObservationType phenomenonType isValid: obsValue
Party
Validator validatorName isValid: obsValue
DiscreteValidator descriptorSet
RangedValidator intervalSet validUnit
PrimitiveObservationType
CompositeObservationType
NullValidator
Slide Slide -- 5252
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Party
Primitive Observation observationValue
CompositeObservation
Observation recordedDate comments isValid
Quantity unit quantity convertTo:
DiscreteValuesOperational level
Current Design
![Page 53: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/53.jpg)
Observation DesignObservation Design
ObservationType phenomenonType isValid: obsValue
Party
Validator validatorName isValid: obsValue
DiscreteValidator descriptorSet
RangedValidator intervalSet validUnit
PrimitiveObservationType
CompositeObservationType
NullValidator
Knowledge level
Slide Slide -- 5353
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Party
Primitive Observation observationValue
CompositeObservation
Observation recordedDate comments isValid
Quantity unit quantity convertTo:
DiscreteValues
Current Design
![Page 54: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/54.jpg)
anObserv-Type<#COMP-GAL>
aCompObs
Observation DesignObservation Design(instance diagram)
Slide Slide -- 5454
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
aMeasurement<aQuantity>
anObser-Type<#GAL>
anObser-Type<#UDT>
anotherMeasurement<anotherQuantity>
aRangedValidator
anotherRangedValidator
![Page 55: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/55.jpg)
anInfant nameobsCollection
aMeasurement type value
anObservationType #GestationalAge
aQuantity value <36> unit <weeks>
aDiscreteValidator
Observation DesignObservation Design(instance diagram)
aRangedValidator
Slide Slide -- 5555
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
anotherRangedValidator
anObserv-Type<#COMP-GAL>
aMeasurement<aQuantity>
aCompObs
anObser-Type<#GAL>
anotherMeasurement<anotherQuantity>
anObser-Type<#UDT>
aRangedValidator
![Page 56: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/56.jpg)
Observations: TypeObject
TypeObject
1..* elements
1 descriptor
elements 1..*
1..*instance
ObservationTypephenomenonTypeisValid: obsValue
ObservationrecordedDatecommentsisValid
Quantity
Slide Slide -- 5656
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Primitive ObservationobservationValue
CompositeObservation
PrimitiveObservationType
CompositeObservationType
QuantityunitquantityconvertTo:
DiscreteValues
Operational level
value 1..*
dvalue 1..*Knowledge level
![Page 57: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/57.jpg)
Observations: Properties
properties1..*
1..*
Party
Observation
Slide Slide -- 5757
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
elements 1..*
1..*instance
Primitive ObservationobservationValue
CompositeObservation
ObservationrecordedDatecommentsisValid
QuantityunitquantityconvertTo:
DiscreteValuesOperational level
value 1..*
dvalue 1..*Knowledge level
![Page 58: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/58.jpg)
Observations: TypeSquarecontDescr 1
1 descriptor1..* elements
1..* varTypeObservationTypephenomenonTypeisValid: obsValue
Party
PrimitiveObservationType
CompositeObservationType
PartyType
1 descriptor
properties1..*
1..*
Slide Slide -- 5858
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
elements 1..*
1..*instance
Primitive ObservationobservationValue
CompositeObservation
ObservationrecordedDatecommentsisValid
QuantityunitquantityconvertTo:
DiscreteValuesOperational level
1..*
value 1..*
dvalue 1..*
Knowledge level
![Page 59: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/59.jpg)
Observations: Strategy
guard 1ObservationType
phenomenonTypeisValid: obsValue
ValidatorvalidatorNameisValid: obsValue1..* elements
1..* type
Slide Slide -- 5959
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
DiscreteValidatordescriptorSet
RangedValidatorintervalSetvalidUnit
PrimitiveObservationType
CompositeObservationType
NullValidator
Operational level
Knowledge level
![Page 60: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/60.jpg)
Medical Observations Design
1 descriptor
ObservationTypephenomenonTypeisValid: obsValue
Party
ValidatorvalidatorNameisValid: obsValue
DiscreteValidatordescriptorSet
RangedValidatorintervalSetvalidUnitPrimitiveObservation
TypeCompositeObservation
Type
NullValidator1..* elements
guard 11..* type
PartyType
1 descriptor
properties
1..*
1..* varType
contDescr 1Entities
Slide Slide -- 6060
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
elements 1..*
1..*instance
Primitive ObservationobservationValue
CompositeObservation
ObservationrecordedDatecommentsisValid
QuantityunitquantityconvertTo:
DiscreteValuesOperational level
properties1..*
value 1..*
dvalue 1..*
Knowledge level
Attributes
Behavior
![Page 61: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/61.jpg)
Strategies/Interpreters/RuleObjects(Behavior/Methods)
SomeStrategy
+sharedInterface()-sharedAttributes : someType
Strategy1 Strategy2 StragegyN
...
Entity
+someOperations()-specificAttribues : type
*
*
1
1
RuleObject
*
Slide Slide -- 6161
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Design Patterns - GOF95
Composite Strategies Interpreter
Strategy2.1 Strategy2.2
PrimitiveRule CompositeRule
ANDCondition ORCondition NOTCondition
1
![Page 62: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/62.jpg)
Composite Strategies
Problem: Strategy leads to a big class hierarchy, one class for each kind of policy.
Slide Slide -- 6262
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Solution: Make Composite Strategies using Primitive Operations.
=> Interpreter pattern
![Page 63: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/63.jpg)
Adaptive Object Model Adaptive Object Model “Common Architecture”“Common Architecture”
Classes with Attributes andRelationships
Behavior
Slide Slide -- 6363
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Operational Knowledge (meta)
![Page 64: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/64.jpg)
Process for Developing Adaptable Systems
Developed Iteratively and Incrementally.
Be Agile, Scrum, XP, Retrospective
Get Customer Feedback early and often.
User Scenarios – User Stories…
Slide Slide -- 6464
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Add flexibility only when and where needed.
Provide Test Cases and Suites for both theObject-Model and the Meta-Model.
Develop Support Tools and Editors for manipulating the metadata.
Very similar to Evolving Frameworksby Roberts and Johnson PLoPD3
![Page 65: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/65.jpg)
Refactoring Addresses SomeKey Leverage Points
Refactoring is a technique that works with Brooks’ “promising attacks” (from “No Silver Bullet”):
buy rather than build: restructuring interfaces to support commercial SW
Slide Slide -- 6565
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
grow don’t build software: software growth involves restructuring (isn’t this core to Agile???)
requirements refinements and rapid prototyping: refactoring supports such design exploration, and adapting to changing customer needs
support great designers: a tool in a designer’s tool chest.
![Page 66: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/66.jpg)
Papers and Web Sites
Bill Opdyke’s Thesis
Don Robert’s Thesishttp://st-www.cs.illinois.edu/users/droberts/thesis.pdf
R f t i B
Slide Slide -- 6666
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
Refactoring Browserhttp://st-www.cs.illinois.edu/users/brant/Refactory
Evolving Frameworkshttp://st-www.cs.uiuc.edu/users/droberts/evolve.html
Extreme Programminghttp://www.c2.com/cgi-bin/wiki?ExtremeProgramming
![Page 67: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/67.jpg)
More Web Sites
Wiki wiki webhttp://c2.com/cgi/wiki?WikiPagesAboutRefactoring
The Refactory, Inc.
Slide Slide -- 6767
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.
http://www.refactory.com
Martin Fowler’s Refactoring Pageshttp://www.refactoring.com/
Adaptive Object Modelshttp://www.adaptiveobjectmodel.com/
![Page 68: Agile Refactoring for Making Systems More Adaptableagilcoop.org.br/files/AgileRefactoring.pdf · Short Instructor Bio Joseph Yoder began working with software in the mid 1980’s,](https://reader033.vdocuments.net/reader033/viewer/2022060307/5f09b95b7e708231d4283667/html5/thumbnails/68.jpg)
That’s All
Slide Slide -- 6868
Agile Refactoring for Making Systems More Adaptable Copyright 2009, Joseph W. Yoder & The Refactory, Inc.