Steve Chenoweth, RHIT Ch 12 in Fowler

Slides:



Advertisements
Similar presentations
Chapter 19, 20 Object Oriented Programming (OOP) Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2012.
Advertisements

Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
1 Software Maintenance and Evolution CSSE 575: Session 3, Part 4 Big Refactorings 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.
Refactoring Cristescu Marilena. Definitions Loose Usage: Reorganize a program(or something) As a noun: a change made to the internal structure of some.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
1 Legacy Code From Feathers, Ch 2 Steve Chenoweth, RHIT Right – Your basic Legacy, from Subaru, starting at $ 20,295, 24 city, 32 highway.
Software Engineering CS3003 Lecture 4 Code bad smells and refactoring.
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.
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.
Purpose We wanted to know how students feel about their teachers, specifically Mr. Spencer, Mrs. Davis, Mr. Baird, Mrs. Squire, and Ms. Lund. Note: we.
Software Construction and Evolution - CSSE 375 Dealing with Generalization Steve and Shawn Left – In the 1990 movie “The Freshman,” Matthew Broderick,
Module 9. Dealing with Generalization Course: Refactoring.
CSCE 240 – Intro to Software Engineering Lecture 3.
ICONFINDER ICONFINDER Founded Django based web application -PostgreSQL -Elasticsearch -Amazon Elastic Compute.
LIFE SKILLS What is the definition of a life skill?
Principles and examples
Year 5 - Numeracy Title page..
Steve Chenoweth Office Phone: (812) Cell: (937)
Am I a Bully? Introduce topic to students. Remind them that they’ve already had a lesson on being bullied and what to do about it. This lesson is about.
Phil Tayco Slide version 1.0 Created Sep 18, 2017
Inheritance Based on slides by Ethan Apter
Steve Chenoweth Office Phone: (812) Cell: (937)
EXPLORING descriptions of SPREAD Math 6 Plus Unit 13
7/20/2018 EMR 17 Logical Reasoning Lecture 7.
D.A.R.E By: Avery Meechan.
Dealing with Bullying? Don’t Call Me Names
Weather & Water.
AFP - Lecture 2 Domain Specific Embedded Languages
EXPLORING descriptions of SPREAD UNIT 13
Lecture 2 Domain Specific Embedded Languages
Understand Windows Forms Applications and Console-based Applications
Orientation Programme Positive Parenting
Content Best Practices
Learning to program with Logo
Helpful Tips and Tricks for Reading in World History
CS2102: Lecture on Abstract Classes and Inheritance
Objects First with Java
lecture 08, OO Design Principle
Enterprise Architecture Patterns
I can stay true to myself despite external pressures
OO Design Patterns - Decorator
Making Procedural Methods
Opinion Fact and Opinion Writing.
HAPPY NEW YEAR! Lesson 7: If-statements unplugged
Refactoring and Code Smells
Use Case Model Use case diagram – Part 2.
Git CS Fall 2018.
I can work with different people in my class
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
Working in Groups.
I can stay true to myself despite external pressures
Border Layout, using Panels, Introduction to PinBallGame
Workshop for Programming And Systems Management Teachers
Refactoring and Code Smells
Chapter 9 Inheritance.
Learning outcomes Knowledge Skills
Applying Use Cases (Chapters 25,26)
Keeping Safe at CVPS with ALiCE
EXPLORING descriptions of SPREAD Math6-UNIT 10
creating a ecosystems model in net logo
Flexible thinking We are learning to understand that people may say things that mean something different from what we thought they meant We are learning.
HFOOAD Chapter 5 Interlude
EXPLORING descriptions of SPREAD
Refactoring.
Refactoring and Code Smells
Presentation transcript:

Steve Chenoweth, RHIT Ch 12 in Fowler Big Refactorings Steve Chenoweth, RHIT Ch 12 in Fowler Above – Man on wire – Big refactorings feel just as dangerous, even if they are not, because you may hit intermediate stages during which you can’t immediately test if the system still works, or not. Image of Philippe Petit walking between the World Trade Center towers, Aug 7, 1974, from http://simpleprogrammer.com/2010/10/01/living-dangerously-refactoring-without-a-safety-net/.

This is the big win Make better sense of big chunks of code. Consider them first, not last! Typical situations: Big inheritance mess. Small parts of something that became big parts. Dependencies that grew and grew. Areas you know are hard to maintain. Q1: Fowler says that usually you are “refactoring to some purpose.” Why does that mean you should consider Big Refactorings before all the little ones we’ve studied so far ? Q1

Teasing apart inheritance A hierarchy that does two different jobs. Pick the important job – keep in current hierarchy. Use Extract Class to get rid of subsidiary job. Decide if subclasses are needed for these. Use Move Method to move the behavior over, Till the offending subclass has no more code! Q2: Ok, teasing apart inheritance does look like a big refactoring which would take time. What’s the most likely situation where you would want to take time to do it, anyway? What’s the next most likely situation? Q2

Fowler’s example: The trick is to know the basis for pulling it apart: Like, “Are we going to add yet another presentation style?” From http://sourcemaking.com/refactoring/tease-apart-inheritance

Converting Procedural Designs to Objects Common in C, C++, etc. systems. People bad at OO also write Java, C# this way! Record types become dumb data objects with accessors. Start with a single class. Use Extract Method on long procedures. Move to the proper dumb data class. Try to pull all the code from the original class or module. Q3: In converting procedural designs to OO, what do “functions” turn into? Q4: In converting to OO, why do you start with making record types into the start of new classes? Q5: Why do you try to remove all the code from the original class or module? Q3, 4, 5

Separate Domain from Presentation The most common offender – a “freshman” design style. Create a design class for each window. Represent complex data presented, like rows of a grid. Decide if data is UI or domain, separate! Examine logic and use Extract Method to separate. Q6: Ok, you’re now a junior, not a freshman. How could you fall into the trap of mixing domain code with presentation? Q6

Fowler’s example: Great questions for any system might be: “Can we add an iOS interface?” Or, “Can we test just the domain part?” From http://sourcemaking.com/refactoring/separate-domain-from-presentation

Extract Hierarchy Take the class that’s one giant conditional, and create a hierarchy of subclasses based on the logic. This one is done like you’ve already been doing them. Image from http://en.wikipedia.org/wiki/Paul_Graham_%28computer_programmer%29. Q7: Suppose you wanted to represent, as OO classes, the “Hierarchy of Disagreement” shown on slide 6. Why would the bottom level, name-calling, most likely be close to the highest level parent in your class hierarchy, and the top level, “refuting the central point,” be close to the lowest-level child in the hierarchy? Right – Programmer Paul Graham’s “Hierarchy of disagreement.” He claims that, the higher you can go in the hierarchy, when disagreeing with someone, the less likely you are to offend them personally. Q7