SlideShare a Scribd company logo
1 of 34
삶이 편해지는 쉬운 리팩토링(Refactoring)
유석문
http://xaxor.com/bizarre/23678-dangerou
s-work-part-4-construction-workers.html
Refactoring?!?!!
What is Refactoring?
A change made to the internal structure of software to make it
easier to understand and cheaper to modify without changing its
observable behavior. — Refactoring, Martin Fowler, page 53.
Refactoring typically involves
• Removing duplicated or dead code
• Simplifying complex code
• Clarifying unclear code
Refactoring is revision
All good writing is based upon revision.
— Jacques Barzun, Simple & Direct, 4th Edition
Revision means to re-see or see again.
How to Refactor
The secret to successful refactoring is to
take baby steps.
When refactoring, your ultimate goal is not to:
• break anything
• make things worse
• introduce new behavior
How to Refactor
• Verify that all automated tests (unit tests) pass
• Decide what code to change
• Implement one or more refactorings carefully
• Run the unit tests whenever you wish to confirm that changes ha
ve not altered system behavior
• Repeat until the refactoring is complete or revert to an earlier
state
Refactoring?!?!!
http://daily-pins.com/there-was-a-spider-its-gone-now/
A Chicken and Egg Problem?
Many people, when they first encounter the concept of unit testing and
refactoring legacy code, consider it a chicken-and-egg conundrum:
Can't do one without having the other.
Unit Testing Refactoring
Start with the Universals
Always start refactoring work with the three universals.
1. Reformat and Commit. Establish a baseline for later diffs.
2. Eliminate the Noise. A refactored file always minimizes noise and m
aximizes signal.
3. Get To Testability. We're going to need some tests. Can we even st
art to test our class?
Consolidate Conditional Expression
Clarity
"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand."
— Martin Fowler, Refactoring
Extract Hierarchy
Highly Cohesive
Methods do only one thing and classes have a single, clear responsibility.
Extract Superclass
Duplication Free
A program should express each idea once and only once. Code may not
always appear to be identical and yet may be expressing the same logic
and information. Duplicate code may diverge to become out of sync
Hide Method
Encapsulated
A form of information hiding, code that is encapsulated
does not expose data or behavior that should be invisible
Inline Method
Simple
Code reflects the shortest path to a solution and incorporates
only enough complexity to handle its known responsibilities.
Simple code is easier to maintain and evolve.
Caller Creates
When you need to create a new class or method that will be invoked by a
caller, don't perform the creation where the new code will reside (e.g. in a
new file or within the class that will contain the new method).
Instead, declare the to-be-created class/method where it will be used, i.e.
in the caller code.
This will allow you to use IDE tools to automatically generate the exact co
de needed by the client, instead of retrofitting client code to the new class/
method after creation.
Automated Refactorings
Rejected Parameter
To avoid passing a parameter to code you want to extract, you must first rej
ect the parameter from the extraction.
The video on the next page presents three different ways to reject a
parameter:
1. Inline the unwanted parameter.
2. Move the unwanted parameter out of the extraction block.
3. Turn the unwanted parameter into a field so it can be referenced from t
he extracted method instead of being passed as a parameter.
Move (Caller Swap)
Move responsibilities from a caller to a parameter
by calling the parameter with the original caller as its parameter.
Encapsulated Dependency
Before moving code to a new class, first encapsulate
dependencies, like fields.
Remove Duplication by Extract Method - Before
Remove Duplication - After
Sample
Removing A Long Method Smell
Removing A Long Method Smell (Composed Method)
Removing Unnecessary hierarchy
Removing Unnecessary hierarchy
Change hierarchy
A Map holds keys and values,
whereas List and Set just
hold objects.
Duplicated Fields & Methods
Duplicated Fields & Methods in List and Set
AbstractCollection's method, addAll(...), contains
the smells Long Method, Duplicated Code , Switch St
atement and Alternative Classes With Different Interfa
ces
Duplicated Fields & Methods
Don’t Fix Bugs during Refactoring
A List should allow duplicates, yet in
AbstractCollection your addAll(...) method is
checking whether the element is already
contained before adding it.
There is a time and place to fix bugs and it is
not during refactoring.
Primitive Obsession In Map
Map suffers from the Primitive Obsession smell
because it wastes too much code manipulating
the keys and values arrays.
Scaffolding
Builders make changes to
buildings by first putting up
scaffolding to make their workea
sier and safer.
Extract Method refactoring to produce:
getValueAt(...)
setValueAt(...)
When you no longer need your scaffolding, you can remove it by
applying the Inline Method refactoring.
A Temporary Field In Map
Map has a field called indexWhereKeyFound that is a p
rime example of the Temporary Field Smell.
Thank you.

More Related Content

What's hot

Unit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqUnit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqXPDays
 
Automating C# Coding Standards using StyleCop and FxCop
Automating C# Coding Standards using StyleCop and FxCopAutomating C# Coding Standards using StyleCop and FxCop
Automating C# Coding Standards using StyleCop and FxCopBlackRabbitCoder
 
Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testingmarkstory
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy CodeExcella
 
Presenter deck icenium hol
Presenter deck   icenium holPresenter deck   icenium hol
Presenter deck icenium holDhananjay Kumar
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
 
Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Noopur Gupta
 
Object-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingObject-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingAllan Mangune
 
Eclipse Tips & Tricks - EclipseCon North America 2014
Eclipse Tips & Tricks - EclipseCon North America 2014Eclipse Tips & Tricks - EclipseCon North America 2014
Eclipse Tips & Tricks - EclipseCon North America 2014Noopur Gupta
 
Writing Testable Code
Writing Testable CodeWriting Testable Code
Writing Testable Codejameshalsall
 
c3ee900a-894b-4680-894c-42f77ffd4446-160308162303
c3ee900a-894b-4680-894c-42f77ffd4446-160308162303c3ee900a-894b-4680-894c-42f77ffd4446-160308162303
c3ee900a-894b-4680-894c-42f77ffd4446-160308162303Robert Warren
 
Eclipse Luna - What's New!
Eclipse Luna - What's New!Eclipse Luna - What's New!
Eclipse Luna - What's New!Noopur Gupta
 
JDT Embraces Lambda Expressions - EclipseCon North America 2014
JDT Embraces Lambda Expressions - EclipseCon North America 2014JDT Embraces Lambda Expressions - EclipseCon North America 2014
JDT Embraces Lambda Expressions - EclipseCon North America 2014Noopur Gupta
 
FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09Pyxis Technologies
 
Behaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlowBehaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlowPascal Laurin
 
A Beginer's Guide to testing in Django
A Beginer's Guide to testing in DjangoA Beginer's Guide to testing in Django
A Beginer's Guide to testing in DjangoPsalms Kalu
 

What's hot (20)

Unit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and MoqUnit Testing in Action - C#, NUnit, and Moq
Unit Testing in Action - C#, NUnit, and Moq
 
Automating C# Coding Standards using StyleCop and FxCop
Automating C# Coding Standards using StyleCop and FxCopAutomating C# Coding Standards using StyleCop and FxCop
Automating C# Coding Standards using StyleCop and FxCop
 
Win at life with unit testing
Win at life with unit testingWin at life with unit testing
Win at life with unit testing
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
Presenter deck icenium hol
Presenter deck   icenium holPresenter deck   icenium hol
Presenter deck icenium hol
 
Bdd and spec flow
Bdd and spec flowBdd and spec flow
Bdd and spec flow
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013
 
Object-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & ProgrammingObject-oriented Analysis, Design & Programming
Object-oriented Analysis, Design & Programming
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
Automated testing
Automated testingAutomated testing
Automated testing
 
PHPUnit - Unit testing
PHPUnit - Unit testingPHPUnit - Unit testing
PHPUnit - Unit testing
 
Eclipse Tips & Tricks - EclipseCon North America 2014
Eclipse Tips & Tricks - EclipseCon North America 2014Eclipse Tips & Tricks - EclipseCon North America 2014
Eclipse Tips & Tricks - EclipseCon North America 2014
 
Writing Testable Code
Writing Testable CodeWriting Testable Code
Writing Testable Code
 
c3ee900a-894b-4680-894c-42f77ffd4446-160308162303
c3ee900a-894b-4680-894c-42f77ffd4446-160308162303c3ee900a-894b-4680-894c-42f77ffd4446-160308162303
c3ee900a-894b-4680-894c-42f77ffd4446-160308162303
 
Eclipse Luna - What's New!
Eclipse Luna - What's New!Eclipse Luna - What's New!
Eclipse Luna - What's New!
 
JDT Embraces Lambda Expressions - EclipseCon North America 2014
JDT Embraces Lambda Expressions - EclipseCon North America 2014JDT Embraces Lambda Expressions - EclipseCon North America 2014
JDT Embraces Lambda Expressions - EclipseCon North America 2014
 
FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09
 
Behaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlowBehaviour Driven Development with SpecFlow
Behaviour Driven Development with SpecFlow
 
A Beginer's Guide to testing in Django
A Beginer's Guide to testing in DjangoA Beginer's Guide to testing in Django
A Beginer's Guide to testing in Django
 

Similar to Agile korea 2013 유석문

Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeValerio Maggio
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerIgor Crvenov
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Myeongseok Baek
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...DevDay.org
 
Refactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopRefactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopMax Kleiner
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@Alex Borsuk
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop Itzik Saban
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix Solutions
 
Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16Adi Bolboaca
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smellskim.mens
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean CodingMetin Ogurlu
 
C#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New FeaturesC#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New Featurestechfreak
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddSrinivasa GV
 

Similar to Agile korea 2013 유석문 (20)

Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Refactoring: Improve the design of existing code
Refactoring: Improve the design of existing codeRefactoring: Improve the design of existing code
Refactoring: Improve the design of existing code
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
 
Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기Ddc2011 효과적으로레거시코드다루기
Ddc2011 효과적으로레거시코드다루기
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
 
Refactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_WorkshopRefactoring_Rosenheim_2008_Workshop
Refactoring_Rosenheim_2008_Workshop
 
Unit Testing Full@
Unit Testing Full@Unit Testing Full@
Unit Testing Full@
 
Reduce Reuse Refactor
Reduce Reuse RefactorReduce Reuse Refactor
Reduce Reuse Refactor
 
Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
 
Chapter-3 Scoping.pptx
Chapter-3 Scoping.pptxChapter-3 Scoping.pptx
Chapter-3 Scoping.pptx
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16Legacy Coderetreat @Budapest 2013 02 16
Legacy Coderetreat @Budapest 2013 02 16
 
Bad Code Smells
Bad Code SmellsBad Code Smells
Bad Code Smells
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
 
C#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New FeaturesC#3.0 & Vb 9.0 New Features
C#3.0 & Vb 9.0 New Features
 
Code smell overview
Code smell overviewCode smell overview
Code smell overview
 
Refactoring
RefactoringRefactoring
Refactoring
 
Refactoring
RefactoringRefactoring
Refactoring
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tdd
 

More from Sangcheol Hwang

Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4Sangcheol Hwang
 
사티어 빙산의사소통 방법론
사티어 빙산의사소통 방법론사티어 빙산의사소통 방법론
사티어 빙산의사소통 방법론Sangcheol Hwang
 
DevOpsday 2013 SiliconValley
DevOpsday 2013 SiliconValleyDevOpsday 2013 SiliconValley
DevOpsday 2013 SiliconValleySangcheol Hwang
 
Velocity 2013 Conference
Velocity 2013 ConferenceVelocity 2013 Conference
Velocity 2013 ConferenceSangcheol Hwang
 
Tdd retro agile_korea_게시용
Tdd retro agile_korea_게시용Tdd retro agile_korea_게시용
Tdd retro agile_korea_게시용Sangcheol Hwang
 
협업도구 및 주요 Agile practices 적용사례 v1.0
협업도구 및 주요 Agile practices 적용사례 v1.0협업도구 및 주요 Agile practices 적용사례 v1.0
협업도구 및 주요 Agile practices 적용사례 v1.0Sangcheol Hwang
 
Agile planning & estimating joshua partogi
Agile planning & estimating joshua partogiAgile planning & estimating joshua partogi
Agile planning & estimating joshua partogiSangcheol Hwang
 
Lab80 unicorn ranch-agilekorea2012
Lab80 unicorn ranch-agilekorea2012Lab80 unicorn ranch-agilekorea2012
Lab80 unicorn ranch-agilekorea2012Sangcheol Hwang
 
애자일하게스펙작성하기
애자일하게스펙작성하기애자일하게스펙작성하기
애자일하게스펙작성하기Sangcheol Hwang
 
애자일에대한오해와진실
애자일에대한오해와진실애자일에대한오해와진실
애자일에대한오해와진실Sangcheol Hwang
 
칸반게임소개 20100810
칸반게임소개 20100810칸반게임소개 20100810
칸반게임소개 20100810Sangcheol Hwang
 
애자일 아키텍트를 위한 툴 박스
애자일 아키텍트를 위한 툴 박스애자일 아키텍트를 위한 툴 박스
애자일 아키텍트를 위한 툴 박스Sangcheol Hwang
 

More from Sangcheol Hwang (14)

Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
Tech planet 2015 Docker 클라우드 구축 프로젝트 - d4
 
DevOps with Docker
DevOps with DockerDevOps with Docker
DevOps with Docker
 
사티어 빙산의사소통 방법론
사티어 빙산의사소통 방법론사티어 빙산의사소통 방법론
사티어 빙산의사소통 방법론
 
DevOpsday 2013 SiliconValley
DevOpsday 2013 SiliconValleyDevOpsday 2013 SiliconValley
DevOpsday 2013 SiliconValley
 
Velocity 2013 Conference
Velocity 2013 ConferenceVelocity 2013 Conference
Velocity 2013 Conference
 
Tdd retro agile_korea_게시용
Tdd retro agile_korea_게시용Tdd retro agile_korea_게시용
Tdd retro agile_korea_게시용
 
협업도구 및 주요 Agile practices 적용사례 v1.0
협업도구 및 주요 Agile practices 적용사례 v1.0협업도구 및 주요 Agile practices 적용사례 v1.0
협업도구 및 주요 Agile practices 적용사례 v1.0
 
Lean startupinpractice
Lean startupinpracticeLean startupinpractice
Lean startupinpractice
 
Agile planning & estimating joshua partogi
Agile planning & estimating joshua partogiAgile planning & estimating joshua partogi
Agile planning & estimating joshua partogi
 
Lab80 unicorn ranch-agilekorea2012
Lab80 unicorn ranch-agilekorea2012Lab80 unicorn ranch-agilekorea2012
Lab80 unicorn ranch-agilekorea2012
 
애자일하게스펙작성하기
애자일하게스펙작성하기애자일하게스펙작성하기
애자일하게스펙작성하기
 
애자일에대한오해와진실
애자일에대한오해와진실애자일에대한오해와진실
애자일에대한오해와진실
 
칸반게임소개 20100810
칸반게임소개 20100810칸반게임소개 20100810
칸반게임소개 20100810
 
애자일 아키텍트를 위한 툴 박스
애자일 아키텍트를 위한 툴 박스애자일 아키텍트를 위한 툴 박스
애자일 아키텍트를 위한 툴 박스
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 

Agile korea 2013 유석문

  • 1. 삶이 편해지는 쉬운 리팩토링(Refactoring) 유석문
  • 3. What is Refactoring? A change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior. — Refactoring, Martin Fowler, page 53. Refactoring typically involves • Removing duplicated or dead code • Simplifying complex code • Clarifying unclear code
  • 4. Refactoring is revision All good writing is based upon revision. — Jacques Barzun, Simple & Direct, 4th Edition Revision means to re-see or see again.
  • 5. How to Refactor The secret to successful refactoring is to take baby steps. When refactoring, your ultimate goal is not to: • break anything • make things worse • introduce new behavior
  • 6. How to Refactor • Verify that all automated tests (unit tests) pass • Decide what code to change • Implement one or more refactorings carefully • Run the unit tests whenever you wish to confirm that changes ha ve not altered system behavior • Repeat until the refactoring is complete or revert to an earlier state
  • 8. A Chicken and Egg Problem? Many people, when they first encounter the concept of unit testing and refactoring legacy code, consider it a chicken-and-egg conundrum: Can't do one without having the other. Unit Testing Refactoring
  • 9. Start with the Universals Always start refactoring work with the three universals. 1. Reformat and Commit. Establish a baseline for later diffs. 2. Eliminate the Noise. A refactored file always minimizes noise and m aximizes signal. 3. Get To Testability. We're going to need some tests. Can we even st art to test our class?
  • 10. Consolidate Conditional Expression Clarity "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." — Martin Fowler, Refactoring
  • 11. Extract Hierarchy Highly Cohesive Methods do only one thing and classes have a single, clear responsibility.
  • 12. Extract Superclass Duplication Free A program should express each idea once and only once. Code may not always appear to be identical and yet may be expressing the same logic and information. Duplicate code may diverge to become out of sync
  • 13. Hide Method Encapsulated A form of information hiding, code that is encapsulated does not expose data or behavior that should be invisible
  • 14. Inline Method Simple Code reflects the shortest path to a solution and incorporates only enough complexity to handle its known responsibilities. Simple code is easier to maintain and evolve.
  • 15. Caller Creates When you need to create a new class or method that will be invoked by a caller, don't perform the creation where the new code will reside (e.g. in a new file or within the class that will contain the new method). Instead, declare the to-be-created class/method where it will be used, i.e. in the caller code. This will allow you to use IDE tools to automatically generate the exact co de needed by the client, instead of retrofitting client code to the new class/ method after creation.
  • 17. Rejected Parameter To avoid passing a parameter to code you want to extract, you must first rej ect the parameter from the extraction. The video on the next page presents three different ways to reject a parameter: 1. Inline the unwanted parameter. 2. Move the unwanted parameter out of the extraction block. 3. Turn the unwanted parameter into a field so it can be referenced from t he extracted method instead of being passed as a parameter.
  • 18. Move (Caller Swap) Move responsibilities from a caller to a parameter by calling the parameter with the original caller as its parameter.
  • 19. Encapsulated Dependency Before moving code to a new class, first encapsulate dependencies, like fields.
  • 20. Remove Duplication by Extract Method - Before
  • 23. Removing A Long Method Smell
  • 24. Removing A Long Method Smell (Composed Method)
  • 27. Change hierarchy A Map holds keys and values, whereas List and Set just hold objects.
  • 28. Duplicated Fields & Methods Duplicated Fields & Methods in List and Set AbstractCollection's method, addAll(...), contains the smells Long Method, Duplicated Code , Switch St atement and Alternative Classes With Different Interfa ces
  • 30. Don’t Fix Bugs during Refactoring A List should allow duplicates, yet in AbstractCollection your addAll(...) method is checking whether the element is already contained before adding it. There is a time and place to fix bugs and it is not during refactoring.
  • 31. Primitive Obsession In Map Map suffers from the Primitive Obsession smell because it wastes too much code manipulating the keys and values arrays.
  • 32. Scaffolding Builders make changes to buildings by first putting up scaffolding to make their workea sier and safer. Extract Method refactoring to produce: getValueAt(...) setValueAt(...) When you no longer need your scaffolding, you can remove it by applying the Inline Method refactoring.
  • 33. A Temporary Field In Map Map has a field called indexWhereKeyFound that is a p rime example of the Temporary Field Smell.