Refactoring Low Level/High Level.

Slides:



Advertisements
Similar presentations
Test-First Programming. The tests should drive you to write the code, the reason you write code is to get a test to succeed, and you should only write.
Advertisements

Clean code. Motivation Total cost = the cost of developing + maintenance cost Maintenance cost = cost of understanding + cost of changes + cost of testing.
A Brief Introduction to Test- Driven Development Shawn M. Jones.
PS4: Test Driven Development Based on Test Driven Development by Example By Kent Beck.
Test-Driven Development “Test first, develop later!” –OCUnit.
By for Test Driven Development: Industry practice and teaching tool Robert Vanderwall, Ph.D. 1 WISTPC-15.
TDD,BDD and Unit Testing in Ruby
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.
Sadegh Aliakbary Sharif University of Technology Spring 2012.
CSE403 ● Software engineering ● sp12 Week 7-10 MondayTuesdayWednesdayThursdayFriday Reading dueGroups Beta due SectionProgress report due Readings out.
Refactoring An Automated Tool for the Tiger Language Leslie A Hensley
1 Legacy Code From Feathers, Ch 2 Steve Chenoweth, RHIT Right – Your basic Legacy, from Subaru, starting at $ 20,295, 24 city, 32 highway.
Test-Driven Development Eduard Miric ă. The problem.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
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,
Refactoring Mehdi Einali Advanced Programming in Java 1.
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.
Software Development. The Software Life Cycle Encompasses all activities from initial analysis until obsolescence Analysis of problem or request Analysis.
TDD Unit tests from a slightly different point of view Katie Dwyer.
Software Development.
FOP: Multi-Screen Apps
Software Engineering Management
Test-driven development
Developer Testing Tricks
Reviewing Code A guide to smelling another developer’s source code.
Steve Chenoweth Office Phone: (812) Cell: (937)
C++ coding standard suggestion… Separate reasoning from action, in every block. Hi, this talk is to suggest a rule (or guideline) to simplify C++ code.
Reviewing your Program
Test Driven Development 1 November Agenda  What is TDD ?  Steps to start  Refactoring  TDD terminology  Benefits  JUnit  Mocktio  Continuous.
Paul Ammann & Jeff Offutt
Making Interactive Information Points (IIP’s) That Audiences Will Love
Extreme Programming.
Advanced Programming in Java
Business Should Adopt Agile Testing. Test Driven Development is an essential software development way that is made by an automated test program which.
Refactoring and Code Smells
Johanna Rothman Create Technical Excellence Chapter 9
Paul Ammann & Jeff Offutt
TDD adoption plan 11/20/2018.
Software Testing and Maintenance Modifying Code
Test-driven development (TDD)
Introduction to Software Testing (2nd edition) Chapter 4 TDD Example
COMP 208/214/215/216 Lecture 3 Planning.
Effective Programming
Programming Basics - RobotC
Refactoring and Code Smells
Small changes to code to improve it
Advanced Programming Behnam Hatami Fall 2017.
Effective Programming
TDD & ATDD 1/15/2019.
SO YOU WANT TO MAKE A GRAPH
Testing Mutable Objects
Coming up: What is Agile?
SO YOU WANT TO MAKE A GRAPH
Refactoring and Code Smells
Tonga Institute of Higher Education IT 141: Information Systems
Applying Use Cases (Chapters 25,26)
Applying Use Cases (Chapters 25,26)
Tonga Institute of Higher Education IT 141: Information Systems
Refactoring and Code Smells
Computational Thinking
You’ll get better code in less time (If you do it for a while)
Life Lessons from Chemistry Class
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
Test Driven Lasse Koskela Chapter 3: Refactoring in Small Steps
Extreme Programming (and Pair Programming)
Refactoring and Code Smells
Presentation transcript:

Refactoring Low Level/High Level

Over Engineering Design Patterns can lead to over-flexible code It is hard to predict the future If certain requirements are never realized, the code is still never removed Code base is too complex So programmers specialize This affects productivity in a subtle way No one wants to get stuck with a bad design

Under Engineering No time to produce good code Don’t know about SW design Add in new stuff quick and dirty Working on too many projects at the same time Look at The Big Ball of Mud

Test Driven Development (TDD) Uses continuous refactoring (in small steps) Write a test Devise code that will pass the test Refine the code Write some more tests Bottom line: Get a small piece of code working correctly before refactoring it

Red, Green Refactor Red: Write a test that tests what your code is supposed to do. Red, because there is no such code Green: Write some code to pass the test Don’t worry about program niceties Refactor: Improve the code that just turned green “Rapid unhurriedness”

Why Refactor? Minimize code duplication Simplify complicated code Make code easier to understand Do this for small improvements--low level Also strive, where relevant, to move towards Design Patterns--high level Try to understand theintent of patterns “Patterns are where you want to be; refactorings are ways to get there from somewhere else.”

What is Refactoring? Refactoring is “a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.” Remove duplicate code Simplify complex logic Clarification of unclear code Test, test, test

Testing Make sure your changes do not break the code Try to automate the testing Refactor in small steps, always testing Download JUnit

Code Clarity Why is Better than june(7,2011); //calling public void date() Better than java.util.Calender c=java.util.Calendar.getInstance(); c.set(2011, java.util.Calendar.JUNE, 7); c.getTime(); Because it is readable and keeps your attention away from distracting code

Other Considerations Keep your code clean Refactor in small steps Remove duplication, achieve better design Refactor in small steps Otherwise spend much time getting back to green If the bar stays red too long take smaller steps

Design Debt It is not always easy to get time to improve your design (boss laughs, you get fired, etc) Managers do not always like refactoring “If it ain’t broke, don’t fix it.” Thus you accrue design debt: code tends to deteriorate The Big Ball of Mud If you don’t pay your debts, you get late fees Getting out of debt gets harder and harder Managers understand this

Evolutionary Design Common Problem: Project division can cause bad communication, wrong code can be written, programmers can wait around. Evolutionary Design Form one team Be application-driven Continuously refactor