Natural Course of Refactoring. A refactoring workflow. Mariusz Sieraczkiewicz @ms_bnsit_pl http://msieraczkiewicz.blogspot.com



Similar documents
Pattern Insight Clone Detection

Indicators. Salesforce SUCCESS Partners

A conversation with Scott Chappell, CMO, Sessions Online Schools of Art and Design

Essentials to Building a Winning Business Case for Tax Technology

02-201: Programming for Scientists

C O N S U L T C O N N E C T - C H A N G E. Does CRM Really Work?

From Raw Data to. Actionable Insights with. MATLAB Analytics. Learn more. Develop predictive models. 1Access and explore data

Efficient BPMN: from Anti-Patterns to Best Practices

P1: OTA/XYZ P2: ABC c01 JWBT043/Goins December 4, :53 Printer Name: Courier Westford, Westford, MA SECTION I

What makes a good process?

Engineering Process Software Qualities Software Architectural Design

Agile methods. Objectives

Monitoring the team s performance

Code Qualities and Coding Practices

Please note the information contained within this document is for Educational purposes only.

COMPELLING SUBJECT LINE SWIPES

Software Development Life Cycle (SDLC)

Scott Lucas: I m Scott Lucas. I m the Director of Product Marketing for the Branch Solutions Business Unit.

How to Study Mathematics Written by Paul Dawkins

A Capability Maturity Model (CMM)

Chapter 12. The Product Coordination Team

The Importance of Data Quality for Intelligent Data Analytics:

Copyright Soleran, Inc. esalestrack On-Demand CRM. Trademarks and all rights reserved. esalestrack is a Soleran product Privacy Statement

XP & Scrum. extreme Programming. XP Roles, cont!d. XP Roles. Functional Tests. project stays on course. about the stories

CALCULATING THE COSTS OF MANUAL REWRITES

Chapter 9 Software Evolution

WEEKLY SAFETY MEETING All Euramax Subsidiaries ACCIDENT REPORTING. Safety Meeting Contents. Meeting Notice. Leaders Guide.

Testing Rails. by Josh Steiner. thoughtbot

Agile Software Development Methodologies and Its Quality Assurance

September 18, Modular development in Magento 2. Igor Miniailo Magento

Returning to work after an injury

Software Engineering. So(ware Evolu1on

From Lab to Factory: The Big Data Management Workbook

Secrets to Automation Success. A White Paper by Paul Merrill, Consultant and Trainer at Beaufort Fairmont, LLC

Etiquette (Netiquette) Guidance

Why Your Job Search Isn t Working

SPECIFICATION BY EXAMPLE. Gojko Adzic. How successful teams deliver the right software. MANNING Shelter Island

Avoiding ERP Implementation Pitfalls. Pre-Purchase Considerations

Patterns to Introduce Continuous Integration to Organizations

Agile development of safety-critical software while meetings standards' requirements

I-Motion SQL Server admin concerns

The USA Mortgage Smart-Loan Guide

Financial Freedom: Three Steps to Creating and Enjoying the Wealth You Deserve

How/why we use Sharepoint

JUnit. Introduction to Unit Testing in Java

Software Service Engineering Architect s Dream or Developer s Nightmare?

Design Patterns for Complex Event Processing

How To Adopt Rup In Your Project

Nova Software Quality Assurance Process

Recovering from a System Crash

So today we shall continue our discussion on the search engines and web crawlers. (Refer Slide Time: 01:02)

Book 3 Cost Estimating in an Agile Development Environment. (early release)

About metrics and reporting in model-based robot assisted functional testing

Intelligent Log Analyzer. André Restivo

An Agile Project Management Model

PROCESS OF MOVING FROM WATERFALL TO AGILE PROJECT MANAGEMENT MODEL

The Integration Between EAI and SOA - Part I

9 Principles of Killer Dashboards SELL. SERVICE. MARKET. SUCCEED.

LEAN SOFTWARE DEVELOPMENT ( As a Survival Tool in Recession )

Software Process for QA

Test-Driven Development

CSC408H Lecture Notes

Automated Acceptance Testing of High Capacity Network Gateway

Prima Solutions. Overcoming the Challenges of Implementation. In This Issue

Agile Software Development

8 Strategies for 2008

Case Study. Driving culture change to achieve WCM status. What LEAP participants are saying about: Leadership. Engagement. Alignment.

Handling the Resource Constraints of Everyday and Special Payroll Tasks

Measuring performance in credit management

Crucial development areas for organizations and how to succeed in them. Leadership Development & Coaching

Transforming Your Patient Data from Paper to Electronic Medical Records. Part of the Power2Practice Practice Management and Efficiency Series

How To Be Successful At An Agile Software Engineering

Improving Employee Satisfaction in Healthcare through Effective Employee Performance Management

UNLEASHING THE POWER

Data Mining Applications in Manufacturing

Agile EAI November 2002 Martin Fowler Gregor Hohpe

SELECTING ECOMMERCE WEB HOSTING & SUPPORT

The ABC s of Communicating with Your Child s School

Why Accountability Matters

Transcription:

Natural Course of Refactoring. A refactoring workflow. Mariusz Sieraczkiewicz @ms_bnsit_pl http://msieraczkiewicz.blogspot.com 1

Why refactoring is like sex? Natural Course of Refactoring

(adapted from http://www.thealmightyguru.com/humor/docs/programmingislikesex.html) Why refactoring is like sex? Once you get started, you ll only stop because you re exhausted. One mistake and the consequences may be really huge. Natural Course of Refactoring 2014 3

(adapted from http://www.thealmightyguru.com/humor/docs/programmingislikesex.html) Why refactoring is like sex? People more talk about it than actually do. You can do it for money or for fun. It s not really an appropriate topic for dinner conversation. Natural Course of Refactoring 2014 4

(adapted from http://www.thealmightyguru.com/humor/docs/programmingislikesex.html) Why refactoring is like sex? Beginners do a lot of noise about it. Some people are just naturally good at it,.. but some people will never realize how bad they are, and you re wasting your time trying to tell them. Natural Course of Refactoring 2014 5

Code readability Natural Course of Refactoring

Why is it difficult to understand software after some time of its evolution?.so!changesintroducing!maybe,software,toso, calledprogressive,and.however.changes!modi fies.usually,structureofmaybe,howevertheco DE,And!wHaTmaYbecumulatEdhowevEr.anD,m Akes.AnD,,and,the.LeSs!rEAdAblE,aNd.cOdeMA ybe.and,!and,!thenumber!of,so,howeversode pendencies,and.maybeinteractions!between HoWevEr!differEntsyStem.moDules!inCreasESo That,iTsO!morE.is.diffiCuLt,To,AnDuNdErstandm odify Natural Course of Refactoring 2014 7

Why is it difficult to understand software after some time of its evolution? Introducing changes to software (so called progressive changes) usually modifies structure of the code, what cumulated makes the code less readable. The number of dependencies and interactions between different system modules increase, so that it is more difficult to understand and modify. Natural Course of Refactoring 2014 8

Flavours of refactoring Natural Course of Refactoring Natural Course of Refactoring 2014 9

Two flavours of refactoring Natural Course of Refactoring 2014 10

Everyday refactoring Everyday refactoring Within a reach of every programmer Can be done in minutes Mostly safe, IDE-base automatic refactorings For local health of the code Part of programming practice No excuse for not doing it Natural Course of Refactoring 2014 11

Strategic refactoring Strategic refactoring A team longer term effort Requires aligning with iteration planning Generates items in backlog Risky activity that requires intensive testing (including good tests suite) Difficult and time-consuming Check carefully if refactoring gives you enough value (Feather s Quadrant) Natural Course of Refactoring 2014 12

When should I do strategic refactoring? Natural Course of Refactoring

Feather s Quadrant Complexity High complexity/ Seldom changes Don t touch it. High complexity/ Frequent changes Apply strategic refactoring Confront with: business vision Frequency of changes Low complexity/ Seldom changes Utils, good for experiments Low complexity/frequent changes Heaven Natural Course of Refactoring 2014 14

Natural Course of Refactoring The process

Natural Course of Refactoring 2014 16

Step 0. Understand the code Natural Course of Refactoring 2014 17

Understand Sometimes it is the most difficult point Try to find an author and ask for help find somebody who worked with the code and ask for help find somebody who knows the system (or module) and ask for help Do it yourself if none of above are possible Natural Course of Refactoring 2014 18

Understand Mental tools Simple code cleaning Clean up the names Add temporary comments to the code Introduce lazy variables initialization Make optical cleanup (make more space) Scratch refactoring Do some exploratory refactoring to be thrown away The only goal is to gain more understanding of the code Natural Course of Refactoring 2014 19

Introduce refactoring comments They should be temporary. Delete them after refactoring. // SMELL it doesn t look good, copy-paste antipattern // REFACTOR introduce factory // NOTE send a message Natural Course of Refactoring 2014 20

Step 1. Express algorithm Natural Course of Refactoring 2014 21

Express algorithm Aim Code that speaks to you Mental tools Compose method Introduce Method Object Refactoring Extract method Naming conditions Natural Course of Refactoring 2014 22

Step 2. Extract responsibilities Natural Course of Refactoring 2014 23

Extract responsibilities Mental tools Single responsibility principle Move method refactoring Extract class refactoring Introduce Domain Object Introduce Value Object Natural Course of Refactoring 2014 24

Step 3. Introduce flexibility Natural Course of Refactoring 2014 25

Apply design patterns Mental tools S.O.L.I.D. Design patterns Refactoring to patterns Natural Course of Refactoring 2014 26

Step 4. Evolve architecture Natural Course of Refactoring 2014 27

Evolve architecture Mental tools Introducing/removing layers Introducing or replacing ORM/NoSQL/? Important change in building blocks Changing or introducing new framework Introducing events Introducing state machine Moving towords DDD, Microservices, CQRS Introducing Bounded-Context (DDD) Applying Anticorruption Layer Natural Course of Refactoring 2014 28

Natural Course of Refactoring 2014 29

Everyday refactoring Strategic refactoring Natural Course of Refactoring 2014 30

NCR IN A TEAM Why NCR? Easy to teach Easy to understand and remeber Separates everyday and strategic refactoring Indicates the simplest (safe) possible step in the moment Gives hints what kind of refactorings can be applied in the moment Natural Course of Refactoring 2014 31

Natural Course of Refactoring. A refactoring workflow. Mariusz Sieraczkiewicz @ms_bnsit_pl http://msieraczkiewicz.blogspot.com 32