Refactoring - 1 CS494: Intro. to Refactoring Readings: –Refactoring for everyone: How and why to use Eclipse's automated refactoring features. By David.

Slides:



Advertisements
Similar presentations
Test-Driven Development José Almeida, Microsoft
Advertisements

Test-Driven Development and Refactoring CPSC 315 – Programming Studio.
A Brief Introduction to Test- Driven Development Shawn M. Jones.
PS4: Test Driven Development Based on Test Driven Development by Example By Kent Beck.
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. What is refactoring ? In refactoring, you start with the basic code and make it better. Change the internal structure of the existing code.
CS 2110 Software Design Principles II Based on slides originally by Juan Altmayer Pizzorno port25.com.
Test-Driven Development and Refactoring Project 3 Lecture 1 CPSC 315 – Programming Studio Fall 2009.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Java Development Tools project.
Introduction to Refactoring Excerpted from ‘What is Refactoring?’ by William C. Wake and Refactoring: Improving the Design of Existing Code by Martin Fowler.
Test-Driven Development “Test first, develop later!” –OCUnit.
Test Driven Development Derived from Dr. Fawcett’s notes Phil Pratt-Szeliga Fall 2009.
Test-Driven Development With Visual Studio 2005 Erno de Weerd Info Support.
Test Driven Development using Visual Studio Team System Ariel Gur-Arieh VP R&D – MCD Software Solutions
Maintenance Refactoring and Code Smells. Where are we? Over the semester we have talked about Software Engineering. The overall goal of software engineering.
Test Driven Development TDD. Testing ”Testing can never demonstrate the absence of errors in software, only their presence” Edsger W. Dijkstra (but it.
Chapter 7 Designing Classes. Class Design When we are developing a piece of software, we want to design the software We don’t want to just sit down and.
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.
Testing in Extreme Programming
Software Refactoring Part I: Introduction Bartosz Walter Advanced Object-Oriented Design Lecture 5.
Sadegh Aliakbary Sharif University of Technology Spring 2012.
Clear Lines Consulting · clear-lines.comSilicon Valley Code Camp 2008 · Nov 8, 2008 · 1 Test-Driven Development An introduction for C# developers.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
© ALEXANDRE CUVA  VERSION 2.00 Test Driven Design.
Software Engineering 1 Object-oriented Analysis and Design Chap 21 Test-Driven Development and Refactoring.
Refactoring Improving the structure of existing code Refactoring1.
CSE403 ● Software engineering ● sp12 Week 7-10 MondayTuesdayWednesdayThursdayFriday Reading dueGroups Beta due SectionProgress report due Readings out.
Refactoring1 Refactoring DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY February 6, 2009.
Refactoring An Automated Tool for the Tiger Language Leslie A Hensley
Refactoring1 Improving the structure of existing code.
Advanced Programming in Java
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.
Software Engineering CS3003 Lecture 4 Code bad smells and refactoring.
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.
Test-Driven Development Eduard Miric ă. The problem.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
1 Software Maintenance and Evolution CSSE 575: Session 2, Part 1 Refactoring Principles Steve Chenoweth Office Phone: (812) Cell: (937)
Scalatest. 2 Test-Driven Development (TDD) TDD is a technique in which you write the tests before you write the code you want to test This seems backward,
Test Driven Development Daniel Brown dxb17u. Introduction Originates from Extreme Programming (XP) Proposed by Kent Beck in Test Driven Development.
1 ECE 750 Topic 8 Meta-programming languages, systems, and applications Evolving Object-Oriented Designs with Refactorings – Lance Tokuda and Don Batory.
Software Design 1.1 CPS 108, Spring 2006 l Object oriented programming and design, we'll use Java and C++  Language independent concepts including design.
Henrik Bærbak Christensen1 Test Driven Development “TDD” Summary.
Refactoring Mehdi Einali Advanced Programming in Java 1.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Refactoring1 Improving the structure of existing code.
Pertemuan 12 Refactoring Mata kuliah: T0144 – Advanced Topics in Software Engineering Tahun: 2010.
Refactoring and Integration Testing or Strategy, introduced reliably by TDD The power of automated tests.
Integrating the Code during the Development Alexander Vakrilov Telerik Corporation
Test Driven Development Introduction Issued date: 8/29/2007 Author: Nguyen Phuc Hai.
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.
Refactoring: Improving the Design of Existing Code.
Continuous Improvement. Start Simple and Continually Improve E.g., Gmail Labels 1.
Java IDE Dwight Deugo Nesa Matic
Software Development. The Software Life Cycle Encompasses all activities from initial analysis until obsolescence Analysis of problem or request Analysis.
Principles and examples
Software Development.
Test Driven Development 1 November Agenda  What is TDD ?  Steps to start  Refactoring  TDD terminology  Benefits  JUnit  Mocktio  Continuous.
Mandatory 1 / AlphaCiv … Traps to be aware of ….
Extreme Programming.
Advanced Programming in Java
Improving the structure of existing code
Refactoring and Code Smells
Advanced Programming Behnam Hatami Fall 2017.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Refactoring and Code Smells
Advanced Programing practices
Refactoring and Code Smells
Presentation transcript:

Refactoring - 1 CS494: Intro. to Refactoring Readings: –Refactoring for everyone: How and why to use Eclipse's automated refactoring features. By David Gallardo ( –Handout from Fowler’s Refactoring book –Optional: Refactoring: Benefits and Disadvantages…”. Web article.Web article

Refactoring - 2 Overview Refactoring: what and why –Reminders: TDD and Unit Testing Tool support (Later: lab exercise)

Refactoring - 3 What Is Refactoring? Definition: –The process of changing software in a way that the external behavior is not altered but the internal structure is improved. –Or, an instance of such a change. (E.g. “I carried out a refactoring….”) Cleaning up code. Improving design. But after the code works. –Fights against software entropy

Refactoring - 4 Why Refactor? Continuous improvement of design –“Tidying up.” Avoids decay. –Needed if “make it work” is first priority –Best design choices may not evident at first Makes software easier to understand –Refactoring done to clean up hacks –Done after reflection. –May be done to remove ambiguity, misleading code, a hack, etc. –If you can change it successfully, you understand it

Refactoring - 5 Why Refactor? (2) Helps you find bugs –A change to improve structure may reveal a flaw in old implementation Helps you developing working code more quickly –Counter-intuitive! –Short cycles of add-functionality then improve-design. (Kent Beck’s “two hats” idea).

Refactoring - 6 But Hold On… Possible objections…. –Touching the design is asking for trouble! –Once it’s working, why bother? –After I think it’s working, don’t I have to re- verify the design changes again? What we need to make refactoring successful is –Unit tests

Refactoring - 7 Reminder slides Remember unit tests? TDD?

Refactoring - 8 Unit Testing in TDD Motto: “Clean code that works.” (Ron Jeffries) Unit testing has “broader goals” that just insuring quality –Improve developers lives (coping, confidence) –Support design flexibility and change –Allow iterative development with working code early

Refactoring - 9 Unit Testing Benefits Developers can work in a predictable way of developing code Programmers write their own unit tests Get rapid response for testing small changes Build many highly-cohesive loosely- coupled modules to make unit testing easier

Refactoring - 10 Red/Green/Refactor The TDD mantra of how to code: –Red: write a little test that doesn’t work, perhaps even doesn’t compile –Green: Write code to make the test work quickly (perhaps not the best code) –Refactor: Eliminate duplication and other problems that you did to just make the test work

Refactoring - 11 When Should Refactor? Remember: afterwards! (After what?) “The Rule of Three” –First, just do it. Second time, do it badly but tolerate it. Third time, do it well: refactor. Some guidelines: –When you need to add a function. Existing design makes this hard. Improve it. –When you need to fix a bug. –As part of a code review.

Refactoring - 12 Refactoring and Design Smells Fowler, design smells, and catalog of refactorings –The book – –List of smells on the web: Refactorings Refactorings

Refactoring - 13 Tool Support for Refactoring Refactorings: standard re-structurings to solve common problems –Can do them by hand –Put might be tricky IDEs and separate tools support this –IntelliJ, ReSharper, JRefactory, C# Refactory –Eclipse, JBuilder, next release of Visual Studio

Refactoring - 14 Reminder Refactorings are often small changes –This are low-level design or code level mods

Refactoring - 15 Why tools? Ponder these: In Java, you decide to change a class’s name. What needs to changed? In Java, you want to change the name of a method. What needs to be changed?

Refactoring - 16 Java Refactorings in Eclipse See help info in Eclipse. And Gallardo article. Renaming resources –classes, methods, fields –moving to another package –inner and anonymous classes Class hierarchy modifications –includes make an interface from a class Code level mods –make a code segment a function