1 Software Maintenance and Evolution CSSE 575: Session 6, Part 4 Breaking Dependencies Steve Chenoweth Office Phone: (812) 877-8974 Cell: (937) 657-3885.

Slides:



Advertisements
Similar presentations
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Advertisements

Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative to refactoring.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Software Construction and Evolution - CSSE 375 Bad Smells in Code Shawn Bohner & Steve Chenoweth.
ITEC200 – Week03 Inheritance and Class Hierarchies.
1 Software Maintenance and Evolution CSSE 575: Session 3, Part 4 Big Refactorings Steve Chenoweth Office Phone: (812) Cell: (937)
1 Software Maintenance and Evolution CSSE 575: Session 2, Part 3 Moving Features Between Objects Steve Chenoweth Office Phone: (812) Cell: (937)
1 Software Maintenance and Evolution CSSE 575: Session 1, Part 4 Even more Bad Smells in Code Steve Chenoweth Office Phone: (812) Cell: (937)
1 Software Maintenance and Evolution CSSE 575: Session 6, Part 1 The “SEAM” Model Steve Chenoweth Office Phone: (812) Cell: (937)
1 Software Maintenance and Evolution CSSE 575: Session 1, Part 1 Course Introduction Steve Chenoweth Office Phone: (812) Cell: (937)
1 Software Maintenance and Evolution CSSE 575: Session 8, Part 3 Predicting Bugs Steve Chenoweth Office Phone: (812) Cell: (937)
1 Steve Chenoweth Tuesday, 10/04/11 Week 5, Day 2 Right – Typical tool for reading out error codes logged by your car’s computer, to help analyze its problems.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Introduction to Refactoring Excerpted from ‘What is Refactoring?’ by William C. Wake and Refactoring: Improving the Design of Existing Code by Martin Fowler.
13-Jul-15 Refactoring II. Books Design Patterns is the classic book by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides Basically a catalog.
Object-Oriented Analysis and Design
Pattern Abstract Factory
(c) University of Washington04-1 CSC 143 Java Inheritance Example (Review)
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Eclipse – making OOP Easy
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
1 Software Maintenance and Evolution CSSE 575: Session 6, Part 2 Problems with Changing Software - 1 Steve Chenoweth Office Phone: (812) Cell:
1 CSSE 375 – Software Construction & Evolution Problems with Changing Software - 2 Steve Chenoweth, RHIT Below – How do you know if your unit test really.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
1 Software Construction and Evolution - CSSE 375 Exception Handling – Logging & Special Situations Steve Chenoweth Office: Moench Room F220 Phone: (812)
CSCI-383 Object-Oriented Programming & Design Lecture 13.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
Refactoring Improving the structure of existing code Refactoring1.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
Chapter 13. Procedural programming vs OOP  Procedural programming focuses on accomplishing tasks (“verbs” are important).  Object-oriented programming.
1 Software Maintenance and Evolution CSSE 575: Session 6, Part 3 Problems with Changing Software - 2 Steve Chenoweth Office Phone: (812) Cell:
Refactoring1 Improving the structure of existing code.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
The Factory Patterns SE-2811 Dr. Mark L. Hornick 1.
Object Oriented Software Development
1 Legacy Code From Feathers, Ch 2 Steve Chenoweth, RHIT Right – Your basic Legacy, from Subaru, starting at $ 20,295, 24 city, 32 highway.
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. Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative.
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.
Question of the Day  Thieves guild states it will sell to members: lock picking kits  $0.67 each 40’ rope  $2.12 each Wire cutters  $4.49 each How.
CSE 425: Control Abstraction I Functions vs. Procedures It is useful to differentiate functions vs. procedures –Procedures have side effects but usually.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
1 Software Maintenance and Evolution CSSE 575: Session 3, Part 3 Dealing with Generalization Steve Chenoweth Office Phone: (812) Cell: (937)
February 8, 2006copyright Thomas Pole , all rights reserved 1 Lecture 3: Reusable Software Packaging: Source Code and Text Chapter 2: Dealing.
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
Copyright © 2009 – Curt Hill Standard Template Library An Introduction.
Refactoring1 Improving the structure of existing code.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
Module 9. Dealing with Generalization Course: Refactoring.
Chapter 9: Continuing Classes By Matt Hirsch. Table Of Contents 1.Static Fields and Methods 2.Inheritance I. Recycle Code with Inheritance II. Overriding.
Copyright 2006 Pearson Addison-Wesley, 2008, 2012 Joey Paquet 1 Concordia University Department of Computer Science and Software Engineering SOEN6441 –
Principles and examples
Steve Chenoweth Office Phone: (812) Cell: (937)
CSC 222: Computer Programming II
Module Road Map Refactoring Why Refactoring? Examples
Names and Attributes Names are a key programming language feature
CS240: Advanced Programming Concepts
Overview of Eclipse Lectures
Code Smells 1.
Improving the structure of existing code
Polymorphism Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2nd edition, by Kernighan.
Data Structures and Algorithms for Information Processing
Refactoring.
Presentation transcript:

1 Software Maintenance and Evolution CSSE 575: Session 6, Part 4 Breaking Dependencies Steve Chenoweth Office Phone: (812) Cell: (937) hulman.eduz Below – From an article on “breaking the last dependency” at 5/04/14/dependency.html. 5/04/14/dependency.html

2 We saw that almost all software changes… Software Changes and Entropy Results – Ripple-Effects of Software Changes – Changes on Changes – Hydra-Effect… Feathers’ book – how to make those changes easy to accomplish – Main trick – Get it into a test-first harness. – Doing that often requires breaking the same dependencies that make the code easy to extend. Reprise - Symbol for Creative Entropy, a company who build iPhone and iPod apps. From

3 Ch 25 – Breaking Dependencies A whole lot of tricks for avoiding testing difficulties – Pick a class you want to work with, but can’t test – Figure out where it should have a “Seam” but doesn’t – Find a way to break that dependency – This presentation’s concept – pick some of those and apply them to making your code more test-friendly Not always easy to isolate things you want to test. 1.blogspot.com/ 1.blogspot.com/

4 Ch 25 – Ways to break ‘em Adapt parameter Break out method object Definition completion Encapsulate global references Express static method Extract and override – – Call – Factory method – Getter Extract – – Implementer – Interface Introduce – – Instance delegator – Static setter Link substitution Parameterize – – Constructor – Method Primitive parameter Pull up feature Push down dependency Replace – – Function with function pointer – Global reference with getter Subclass and override method Supersede instance variable Template redefinition Text redefinition

5 What’s “Extract Interface”? To build test code to replace a part of a messy call – – Create an interface to that messy call, incrementally add only the parts of the real object that you need – The compiler will tell you what’s missing – Make a fake object that implements these corresponding parts, for testing

6 Some of these should look familiar Subclass and override method, for example – We already discussed, in earlier examples – You invent a “testing subclass” and invoke it instead of the real class, to get rid of some dependency – Many of the other Ch 25 methods are variations on this

7 A variation on this one… Push down dependency – can be used when you’d have to define too many interfaces and substitute in too many places, to subclass and override Idea is – – Make the original class abstract, where these dependency problems occur – Subclass it in one way for testing – Subclass it in another to instantiate those problem dependencies for production

8 Common strategy in Ch 25 Build a test harness that includes all these overrides and other ways to simulate things where you need “Seams” Make it clear when you use the test harness or are making it “production.” Perhaps – – The test harness is for a whole system, like in integration testing, or – The test harness is just for unit testing this class

9 Additional Ch 25 tips Be careful creating code that enables testing: – Since the code is not yet testable (till you are done), these changes themselves aren’t “testable” Thus, – Use copy and paste, versus typing – Use code reviews (other people catch errors) – Define testing interfaces (compiler catches errors) Use “mock object libraries” instead of creating your own – See next page for examples!

10

11 Assignment and Milestone Reminders Journals and Milestone this week– – See assignments on course web site. Above – Seams in jeans. From %20Of%20Seams&url= ersforyou.us/big/overlapped_double_sti ched_seams_big.jpg %20Of%20Seams&url= ersforyou.us/big/overlapped_double_sti ched_seams_big.jpg