Refactoring: Improving the Design of Existing Code.

Slides:



Advertisements
Similar presentations
Coding and Debugging. Requirements and Specification Recall the four steps of problem solving: Orient, Plan, Execute, Test Before you start the implementation.
Advertisements

Regression Methodology Einat Ravid. Regression Testing - Definition  The selective retesting of a hardware system that has been modified to ensure that.
The Cathedral and the Bazaar: A Look at Open-Source ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
Processes. Outline Definition of process Type of processes Improvement models Example Next steps… 1.
Refactoring: Improving the Design of Existing Code © Martin Fowler, Martin Fowler.
Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative to refactoring.
Refactoring By: Brian Smith. What is Refactoring? Definition: a change to the internal structure of software to make it easier to understand and cheaper.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Introduction to Refactoring Excerpted from ‘What is Refactoring?’ by William C. Wake and Refactoring: Improving the Design of Existing Code by Martin Fowler.
REFACTORING Improving the Design of Existing Code Atakan Şimşek e
Source Code Management Or Configuration Management: How I learned to Stop Worrying and Hate My Co-workers Less.
Test Driven Development Derived from Dr. Fawcett’s notes Phil Pratt-Szeliga Fall 2009.
Chapter 9 – Software Evolution and Maintenance
By for Test Driven Development: Industry practice and teaching tool Robert Vanderwall, Ph.D. 1 WISTPC-15.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 17 Slide 1 Extreme Programming.
Test Driven Development TDD. Testing ”Testing can never demonstrate the absence of errors in software, only their presence” Edsger W. Dijkstra (but it.
Test Driven Development An approach to writing better code Jimmy Zimmerman Intel Corporation.
Chocolate Bar! luqili. Milestone 3 Speed 11% of final mark 7%: path quality and speed –Some cleverness required for full marks –Implement some A* techniques.
BEFORE AGILE METHODS Other Engineering fields development models were used, ie: Waterfall Method: Intensive planning and refactoring before coding is actually.
Systems Software & Operating systems
Introduction By: Dr. Javad Razjouyan. Programming Languages.
Refactoring: Improving the Design of Existing Code © Martin Fowler, Martin Fowler.
Painless Bug Tracking Michael Tsai 2011/9/30. Reference  html 2.
Refactoring Cristescu Marilena. Definitions Loose Usage: Reorganize a program(or something) As a noun: a change made to the internal structure of some.
1 Lecture 19 Configuration Management Software Engineering.
Programming Languages: Scratch Intro to Scratch. Lower level versus high level Clearly, lower level languages can be tedious Higher level languages quickly.
Software Refactoring Part I: Introduction Bartosz Walter Advanced Object-Oriented Design Lecture 5.
Object-Oriented Programming and the Progress ABL Tomáš Kučera Principal Solution Engineer / EMEA Power Team.
Computer Science 240 © Ken Rodham 2006 Principles of Software Design.
Extreme/Agile Programming Prabhaker Mateti. ACK These slides are collected from many authors along with a few of mine. Many thanks to all these authors.
Refactoring An Automated Tool for the Tiger Language Leslie A Hensley
TEST-1 6. Testing & Refactoring. TEST-2 How we create classes? We think about what a class must do We focus on its implementation We write fields We write.
Debugging and Profiling With some help from Software Carpentry resources.
Refactoring. Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative.
Chapter 7 The Practices: dX. 2 Outline Iterative Development Iterative Development Planning Planning Organizing the Iterations into Management Phases.
AP-1 4. Agile Processes. AP-2 Agile Processes Focus on creating a working system Different attitude on measuring progress XP Scrum.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Improving Design #1 Reduce complexity - narrow-down the project scope - optimize underlying process - eliminate unneeded parts # 2 Find and eliminate redundancies.
1 Software Maintenance and Evolution CSSE 575: Session 2, Part 1 Refactoring Principles Steve Chenoweth Office Phone: (812) Cell: (937)
Refactoring - 1 CS494: Intro. to Refactoring Readings: –Refactoring for everyone: How and why to use Eclipse's automated refactoring features. By David.
WATERFALL DEVELOPMENT MODEL. Waterfall model is LINEAR development lifecycle. This means each phase must be completed before moving onto the next!!! WHAT.
Refactoring Mehdi Einali Advanced Programming in Java 1.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Pertemuan 12 Refactoring Mata kuliah: T0144 – Advanced Topics in Software Engineering Tahun: 2010.
SPI NIGHTLIES Alex Hodgkins. SPI nightlies  Build and test various software projects each night  Provide a nightlies summary page that displays all.
Automated Testing April 2001WISQA Meeting Ronald Utz, Automated Software Testing Analyst April 11, 2001.
Part Time Work Research Chris & Jack. Definition- A job where you don’t work 40hrs in a week. And you don’t get any sort of benefits.
Software Development.
Sample Wiki Comments?.
Steve Chenoweth Office Phone: (812) Cell: (937)
Extreme Programming.
Advanced Programming in Java
Dilbert Scott Adams Manage It! Your Guide to Modern, Pragmatic Project Management. Johanna Rothman.
Some Important Techniques For Regression Testing That You Must Know.
Business Process Reengineering
LESSON 14 - Building an App: Image Scroller
Software Testing and Maintenance Maintenance and Evolution Overview
Introduction to Software Testing (2nd edition) Chapter 4 TDD Example
Advanced Programming Behnam Hatami Fall 2017.
Software visualization and analysis tool box
CSE 303 Concepts and Tools for Software Development
Maintaining a Program In today’s lesson we will look at:
Refactoring.
Discussing an OVS/OVN Split
Integration Reading: McConnell, Code Complete, Ch. 29
Extreme Programming.
Refactoring Low Level/High Level.
Refactoring.
Presentation transcript:

Refactoring: Improving the Design of Existing Code

Definitions of Refactoring »Loose Usage –Reorganize a program »As a noun –a change made to the internal structure of some software to make it easier to understand and cheaper to modify, without changing the observable behavior of that software »As a verb –the activity of restructuring software by applying a series of refactorings without changing the observable behavior of that software.

The Two Hats Adding Function »Add new capabilities to the system »Add new tests »Get the tests working Refactoring rDoes not add any new features rDoes not add tests (but may change some) rRestructure the code to remove redundancy Swap frequently between the hats, but only wear one at a time

Why Refactor »To improve the software design –combats “bit rot” –makes the program easier to change »To make the software easier to understand –write for people, not the compiler –understand unfamiliar code »To help find bugs –refactor while debugging to clarify the code »To program faster –refactoring leads to good design –good design lets you program faster

When should you refactor? »To add new functionality –refactor existing code until you understand it –refactor the design to make it easy to add »To find bugs –refactor to understand the code »For code reviews –immediate effect of code review –allows for higher level suggestions Don’t set aside time for refactoring, include it in your normal activities

Three strikes and you refactor »The first time you do something, you just do it. The second time you do something similar, you wince at the duplication, but you do the duplication thing anyway. The third time you do something similar, you refactor.

When should you NOT refactor? »When the system should be redesigned from scratch »When you're close to a release deadline

Refactoring and Performance »Refactoring leads to lots of small methods, and therefore more indirection »Doesn't all this indirection slow the program down? »Yes, but only temporarily »A well-factored program is easier to optimize

Refactoring and Performance The best way to optimize performance is to first write a well factored program, then optimize it. McConnell Steve, Code Complete: A Practical Handbook of Software Construction, Microsoft Press, 1993 Most of a program’s time is taken in a small part of the code Profile a running program to find these “hot spots” You won’t be able to find them by eye Optimize the hot spots, and measure the improvement

Problems with Refactoring »We don’t know what they all are yet »Database Migration –Insulate persistent database structure from your objects »Published Interfaces –Publish only when you need to –Don’t publish within a development team »Without working tests –Don’t bother

Design Decisions »Planned design –Consider current needs and possible future needs –Design to minimize change with future needs –Patch code if unforeseen need appears »Evolutionary design –Consider current needs and possible future needs –Trade off cost of current flexibility versus cost of later refactoring –Refactor as changes appear martinfowler.com/articles/designDead.html

Design Decisions »One benefit of objects is that they make software easier to change. »Refactoring allows you to improve the design after the code is written »Up front design is still important, but not so critical