You want me to do what??? Refactoring legacy applications aka : fixing someone else’s “bad” code Niel Zeeman Team Foundation Consulting

Slides:



Advertisements
Similar presentations
Test Driven Refactoring by Andreas Thies. XP Test Driven Refactoring2 Overview Refactoring Bad Smells Unit Tests Unit Tests and Refactoring Special.
Advertisements

12-Dec-14 Refactoring IV. Previously discussed bad smells Duplicated code — and other forms of redundancy Long method — use short methods that delegate.
A practical guide John E. Boal TestDrivenDeveloper.com.
© 2010 Shawn A. Bohner Software Construction and Evolution - CSSE 375 Even more Bad Smells in Code Shawn & Steve Q1 Shawn & Steve Hint 
Gregor Gisler-Merz BrownBag Session Refactoring.
Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative to refactoring.
Lectures 17 and 18 A Refactoring Micro-Example FOR0383 Software Quality Assurance 5/16/20151Dr Andy Brooks Refactoring is really easy using this tool.
Software Construction and Evolution - CSSE 375 Bad Smells in Code Shawn Bohner & Steve Chenoweth.
1 Software Maintenance and Evolution CSSE 575: Session 1, Part 4 Even more Bad Smells in Code Steve Chenoweth Office Phone: (812) Cell: (937)
Steve Chenoweth Office Phone: (812) Cell: (937)
Introduction to Refactoring Excerpted from ‘What is Refactoring?’ by William C. Wake and Refactoring: Improving the Design of Existing Code by Martin Fowler.
George Blank University Lecturer. REFACTORING Improving the Design of Existing Code Supplement to Ian Sommerville, Software Engineering, Chapter 20 Prepared.
XP and Refactoring David Talby. Development Methodologies The Software Crisis – 84% of software projects are not on time – 31% of software projects never.
REFACTORING Improving the Design of Existing Code Atakan Şimşek e
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
1 v1.6 08/02/2006 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Refactoring 5.Debugging 6.Testing.
What is Refactoring? CSE301 University of Sunderland Harry R. Erwin, PhD.
Advanced Programing practices
Refactoring Cristescu Marilena. Definitions Loose Usage: Reorganize a program(or something) As a noun: a change made to the internal structure of some.
Software Refactoring Part I: Introduction Bartosz Walter Advanced Object-Oriented Design Lecture 5.
Sadegh Aliakbary Sharif University of Technology Spring 2012.
Chapter 6: Code Refactoring Omar Meqdadi SE 3860 Lecture 6 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Refactoring. Mathematics: Factor ● fac·tor – One of two or more quantities that divides a given quantity without a remainder, e.g., 2 and 3 are factors.
Refactoring - A disciplined approach to rework for better design.
Refactoring Improving the structure of existing code Refactoring1.
Small changes to code to improve it. Refactoring Defined A change made to the internal structure of software to make it easier to understand and cheaper.
Refactoring (continued) Source: "Refactoring: Improving the Design of Existing Code", Martin Fowler.
Refactoring1 Refactoring DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY February 6, 2009.
SWE 316: Software Design and Architecture Objectives Lecture # 20 Improving the existing design: Refactoring SWE 316: Software Design and Architecture.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Improving the Quality of Existing Code Svetlin Nakov Telerik Corporation
Refactoring1 Improving the structure of existing code.
The effectiveness of refactoring based on a compatibility testing taxonomy and a dependency graph Steve Counsell and Robert Hierons, Brunel University,
Refactoring Deciding what to make a superclass or interface is difficult. Some of these refactorings are helpful. Some research items include Inheritance.
Refactoring for Testability (or how I learned to stop worrying and love failing tests) Presented by Aaron Evans.
Housekeeping  SVN  Mandatory for project  Will be a spot check in the next couple of weeks to identify whether “software craftmanship” is being practiced.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Refactoring and such ● (Side note) Specialization ● Key terms ● Abstraction, state, persistence and association and their relationship to software development.
Refactoring: Code Smells. Admin Notes REGISTER FOR BLACKBOARD Watch blackboard site for updates on class as hurricane season approaches.
Refactoring. Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative.
Chapter 21 Test-Driven Development 1CS6359 Fall 2011 John Cole.
E L EARNING E NVIRONMENT FOR S OFTWARE E NGINEERING E DUCATION (R EFACTORING A GENT ) A.Stoyanova-Doycheva University of Plovdiv г. 10th Workshop.
Refactoring 101 William C. Wake
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
REFACTORINGREFACTORING. Realities Code evolves substantially during development Requirements changes 1%-4% per month on a project Current methodologies.
Module 3. Smells Between Classes Course: Refactoring.
How and When to do Refactoring CSE301 University of Sunderland Harry R. Erwin, PhD.
Software Construction and Evolution - CSSE 375 Making Method Calls Simpler Shawn and Steve Below – “Be the character!” The late acting teacher Lee Strasberg.
Refactoring: Improving the Quality of Existing Code
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Refactoring. Mathematics: Factor ● fac·tor – One of two or more quantities that divides a given quantity without a remainder, e.g., 2 and 3 are factors.
CSSE 375 Organizing Data – Part 2 Shawn and Steve Continue the same quiz!
Refactoring1 Improving the structure of existing code.
Pertemuan 12 Refactoring Mata kuliah: T0144 – Advanced Topics in Software Engineering Tahun: 2010.
Refactoring. 2 Process of changing a software system in such a way that it does not alter the external behavior of the code, yet improves its internal.
CSSE 375 Organizing Data – Part 1 Shawn and Steve Q1.
Refactoring. DCS – SWC 2 Refactoring ”A change made to the internal structure of software to make it easier to understand and cheaper to modify without.
Module 9. Dealing with Generalization Course: Refactoring.
Catalog of Refactoring (6) Making Method Calls Simpler.
Principles and examples
Module Road Map Refactoring Why Refactoring? Examples
بازآرایی برنامه Code Refactoring
Overview of Eclipse Lectures
Code Smells 1.
Improving the structure of existing code
Advanced Programming Behnam Hatami Fall 2017.
Advanced Programing practices
Refactoring.
Presentation transcript:

You want me to do what??? Refactoring legacy applications aka : fixing someone else’s “bad” code Niel Zeeman Team Foundation Consulting

Who am I… Consulting Team Foundation

Refactoring Altering internal structure without changing external behavior

Refactoring Small transformations Sequence of transformation can produce significant restructuring Remain fully working

What If it stinks, change it. —Grandma Beck, discussing child-rearing philosophy Smells Duplicated code Long methods Large classes Long param lists Temporary fields Mixed Responsibility Anaemic domains

Why Give ability….. Testability Maintainability Changeability Comprehend ability Applicability

To Refactor or Not to Refactor Code smells IntuitionRe-write Deadlines When

How Begin with the end in mind

SOLID Single Responsibility Open - closed Liskov substitution Interface segregation Dependency inversion

Patterns Extract Method Inline Method Inline Temp Replace method with method object Extract class Move method Remove middle man Replace data value with object Replace record with object Decompose conditional Replace constructor with factory method Replace parameters with parameter object Extract interface Separate domain from presentation interface

Patterns  Add Parameter  Change Bidirectional Association to Unidirectional  Change Reference to Value  Change Unidirectional Association to Bidirectional  Change Value to Reference  Collapse Hierarchy  Consolidate Conditional Expression  Consolidate Duplicate Conditional Fragments  Convert Dynamic to Static Construction by Gerard M. Davison  Convert Static to Dynamic Construction by Gerard M. Davison  Decompose Conditional  Duplicate Observed Data  Eliminate Inter-Entity Bean Communication  Encapsulate Collection  Encapsulate Downcast  Encapsulate Field  Extract Class  Extract Interface  Extract Method  Extract Package by Gerard M. Davison  Extract Subclass  Extract Superclass  Form Template Method  Hide Delegate  Hide Method  Hide presentation tier-specific details from the business tier  Inline Class  Inline Method  Inline Temp  Introduce A Controller  Introduce Assertion  Introduce Business Delegate  Introduce Explaining Variable  Introduce Foreign Method  Introduce Local Extension  Introduce Null Object  Introduce Parameter Object  Introduce Synchronizer Token  Localize Disparate Logic  Merge Session Beans  Move Business Logic to Session  Move Class by Gerard M. Davison  Move Field  Move Method  Parameterize Method  Preserve Whole Object  Pull Up Constructor Body  Pull Up Field  Pull Up Method  Push Down Field  Push Down Method  Reduce Scope of Variable by Mats Henricson  Refactor Architecture by Tiers  Remove Assignments to Parameters  Remove Control Flag  Remove Double Negative by Ashley Frieze and Martin Fowler  Remove Middle Man  Remove Parameter  Remove Setting Method  Rename Method  Replace Array with Object  Replace Conditional with Polymorphism  Replace Conditional with Visitor by Ivan Mitrovic  Replace Constructor with Factory Method  Replace Data Value with Object  Replace Delegation with Inheritance  Replace Error Code with Exception  Replace Exception with Test  Replace Inheritance with Delegation  Replace Iteration with Recursion by Dave Whipp  Replace Magic Number with Symbolic Constant  Replace Method with Method Object  Replace Nested Conditional with Guard Clauses  Replace Parameter with Explicit Methods  Replace Assignment with Initialization by Mats Henricson  Replace Parameter with Method  Replace Record with Data Class  Replace Recursion with Iteration by Ivan Mitrovic  Replace Static Variable with Parameter by Marian Vittek  Replace Subclass with Fields  Replace Temp with Query  Replace Type Code with Class  Replace Type Code with State/Strategy  Replace Type Code with Subclasses  Reverse Conditional by Bill Murphy and Martin Fowler  Self Encapsulate Field  Separate Data Access Code  Separate Query from Modifier  Split Loop by Martin Fowler  Split Temporary Variable  Substitute Algorithm  Use a Connection Pool  Wrap entities with session

presentation Business logic validation persistence

DOMAIN

Step 1 Extract Class / Controller

Step 2 Separate Responsibilities

Q&A (MS PNP) (MS Enterprise Patterns) (MS PNP) (MS Enterprise Patterns) Niel Zeeman Team Foundation Consulting