XP and Refactoring David Talby. Development Methodologies The Software Crisis – 84% of software projects are not on time – 31% of software projects never.

Slides:



Advertisements
Similar presentations
An Introduction to eXtreme Programming Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Advertisements

12-Dec-14 Refactoring IV. Previously discussed bad smells Duplicated code — and other forms of redundancy Long method — use short methods that delegate.
Chapter 2 Modeling the Process and Life Cycle Shari L. Pfleeger
You want me to do what??? Refactoring legacy applications aka : fixing someone else’s “bad” code Niel Zeeman Team Foundation Consulting
Alternate Software Development Methodologies
Agile Process Models. Prescriptive models don’t work It is unrealistic to not have changes. Why? The Agile Manifesto: Individuals and interactions over.
Lectures 17 and 18 A Refactoring Micro-Example FOR0383 Software Quality Assurance 5/16/20151Dr Andy Brooks Refactoring is really easy using this tool.
Programming Tools David Rabinowitz. March 3rd, 2004 Object Oriented Design Course 2 This Lecture Personal Productivity Tools And how to use them Refactoring.
.NET Review Intro to Software Engineering David Talby.
Introduction to Refactoring Excerpted from ‘What is Refactoring?’ by William C. Wake and Refactoring: Improving the Design of Existing Code by Martin Fowler.
Extreme Programming Mark Steverson. What Is Extreme Programming? ● Extreme Programming (XP) is a lightweight, agile methodology developed by Kent Beck.
REFACTORING Improving the Design of Existing Code Atakan Şimşek e
.NET and J2EE Intro to Software Engineering David Talby.
Xtreme Programming. Software Life Cycle The activities that take place between the time software program is first conceived and the time it is finally.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Chapter 5 Software Process Models. Problems with “Traditional” Processes 1.Focused on and oriented towards “large projects” and lengthy development time.
Embracing change with Extreme Programming Method Engineering Erik ten Brinke
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.
CPSC 2150 August 21, Chapter 1 Object Oriented Software Development This is an introductory course In this chapter we will look at 3 topics Challenges.
Coming up: What is Agile? XP Development Dan Fleck 2010 Dan Fleck 2010.
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.
Review: Cohesion and Coupling, Mutable, Inheritance Screen Layouts Software methodologies – Extreme Programming Object-Oriented Design – CRC Cards - UML.
Extreme Programming (XP). Agile Software Development Paradigm Values individuals and interactions over processes and tools. Values working software over.
Extreme Programming.
Refactoring (continued) Source: "Refactoring: Improving the Design of Existing Code", Martin Fowler.
SWE 316: Software Design and Architecture Objectives Lecture # 20 Improving the existing design: Refactoring SWE 316: Software Design and Architecture.
Refactoring An Automated Tool for the Tiger Language Leslie A Hensley
Refactoring1 Improving the structure of existing code.
December Using Software Development Methodology (SDM) in the Third Teaching Unit (laboratory) CS Teachers Conference Dr. Orit Hazzan & Yael Dubinsky.
DAVID STOTTS DEPT. OF COMPUTER SCIENCE UNIV. OF NORTH CAROLINA AT CHAPEL HILL Extreme Programming.
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
Software Engineering CS3003 Lecture 4 Code bad smells and refactoring.
Refactoring: Code Smells. Admin Notes REGISTER FOR BLACKBOARD Watch blackboard site for updates on class as hurricane season approaches.
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.
AP-1 4. Agile Processes. AP-2 Agile Processes Focus on creating a working system Different attitude on measuring progress XP Scrum.
Module 3. Smells Between Classes Course: Refactoring.
Extreme Programming Based on and
1 Software Maintenance and Evolution CSSE 575: Session 2, Part 1 Refactoring Principles Steve Chenoweth Office Phone: (812) Cell: (937)
1 Software Maintenance and Evolution CSSE 575: Session 3, Part 3 Dealing with Generalization Steve Chenoweth Office Phone: (812) Cell: (937)
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.
Agile Methods Presentation By: Jason Abbett. Definition A process to rapidly develop software Many kinds of agile methods but few are practiced.
Extreme Programming. Extreme Programming (XP) Formulated in 1999 by Kent Beck, Ward Cunningham and Ron Jeffries Agile software development methodology.
EXtreme Programming and Open Source engineering paradigm A comparison
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.
Software Construction and Evolution - CSSE 375 Dealing with Generalization Steve and Shawn Left – In the 1990 movie “The Freshman,” Matthew Broderick,
CS223: Software Engineering Lecture 18: The XP. Recap Introduction to Agile Methodology Customer centric approach Issues of Agile methodology Where to.
Introduction to Distributed Objects and Services David Rabinowitz.
Principles and examples
Planning User stories are written.
Extreme Programming.
Programming Tools David Rabinowitz.
بازآرایی برنامه Code Refactoring
Code Smells 1.
Improving the structure of existing code
Advanced Programming Behnam Hatami Fall 2017.
Coming up: What is Agile?
Refactoring.
Refactoring.
Chapter 5: New and Emerging Process Methodologies
Presentation transcript:

XP and Refactoring David Talby

Development Methodologies The Software Crisis – 84% of software projects are not on time – 31% of software projects never complete – Most software is buggy, unstable and insecure – Lack of repeatability (engineering) eXtreme Programming – For small projects: up to 12 people, 100 stories Rational Unified Process – For large projects: a “heavy-weight” process – A commercial product

Rational Unified Process By Rational, see rational.com/ruprational.com/rup Decompose large system to sub-systems – A team and development effort per system – Architects Team does overall design, sharing Five stages of each system’s life cycle – Business modeling, Requirements, Analysis & Design, Implementation, Test – Many artifacts are not code or tests Iterative Development Highly managed, highly automated process

eXtreme Programming By Kent Beck, see XProgramming.comXProgramming.com Embrace change Simplicity User involvement & rapid feedback Incremental pay-as-you-go design Test-first programming

The 12 XP Principles Planning Game Small Releases On-Site Customer Metaphor Simple Design 40-Hour Week Pair Programming Collective Ownership Testing Refactoring Continuous Integration Coding Standard

The XP Principles Develop by iterations of 1-3 weeks each: Plan (user stories) -> design (simplest!) -> test (unit tests) -> code (and refactor) Testing – Functional tests: in design phase – Unit tests as part of coding Continuous Integration Quality Work – Refactoring, 40-Hour Week

Refactoring Improving the design of existing code, without changing its observable behavior Here ’ s the Extract Method refactoring: After: void f() { … computeScore(); } computeScore(int[] a) { // code cut & pasted here } Before: void f(int[] a) { … // compute score score = initial_score; for (int i=0; i<a.length; i++) score += a[i] * delta; }

Why? Why Refactor? – Improve software design – Make software easier to understand – Help find bugs – Help program faster Preconditions – Working code – Good set of unit tests

When? When to refactor – Before adding functionality – Before fixing a bug – During code review When not to refactor – During adding functionality – During fixing a bug – No good set of unit tests – Small programs (usually)

Code Smells “If it stinks, change it” – Duplicate code – Switch statements – Long method – Data class – Long parameter list – Primitive obsession – Temporary field – …

Documented Refactorings There’s a catalog – Fowler’s book – There are many others Way to learn good OOD principles Pay attention to the mechanics There are automatic tools as well – Java Refactoring Browser, refactorit.comrefactorit.com

Encapsulate Field Before: public String name; After: private String name; public String getName() { return name; } public void setName(String n) { name = n; }

Introduce Null Object Before: if (project == null) plan = Plan.default(); else plan = project.getPlan(); After: class NullProject implements Project { public Plan getPlan() { return Plan.default(); } // other Project methods }

Parameterize Method Before: class Server { handleGet( … ) handlePut( … ) handleSet( … ) } After: class Server { handle(EventType et, … ) }

Extract Subclass

Extract Interface

Pull Up Method

Replace Type Code with State/Strategy

Replace Inheritance with Delegation

Hide Delegate Obeys the Law of Demeter

Separate Query from Modifier Obeys Command-Query Separation Database getNextResultAndAdvanceIndex Database getNextResult AdvanceIndex

Introduce Local Extension Alternative: Introduce Foreign Method

The opposites are there too Inline method (extract method) Replace Parameter with Explicit Methods (Parameterize Method) Collapse Hierarchy (Extract subclass) Remove middle man (Hide delegate) Push down method (pull up method) Replace delegation with inheritance

How to Refactor Recognize the smells Refactor in small discrete steps Test after each step Refactor in pairs Use documented refactorings Don’t mix with adding functionality or fixing a bug

Review: OOD Principles Open-Closed Principle Liskov Substitution Principle Single Choice Principle Law of Demeter Command-Query Separation Interface Segregation Principle, a.k.a. Single Responsibility Principle Dependency Inversion Principle