SlideShare a Scribd company logo
1 of 8
Download to read offline
Refactoring
FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
Refactoring
■ Process of changing a software system in such a way that it does not change its
external behavior but improves its internal structure
■ Restructure a software without changing its observable behavior
■ Improving the code of a software without adding new functionality or changing any
existing functionality
■ Process of cleaning up the code of a software without changing its output
– Enhances the readability of code
– Reduces the complexity in code
– Improves the maintainabilityof code
– Provides the extensibility for code
FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
Principles in Refactoring
FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
Principles in Refactoring
■ Why refactor?
– Improves the design of software
– Makes software easier to understand
– Helps in finding bugs
– Helps in programming faster
■ When to refactor?
– On adding a functionality
– On fixing an error
– On reviewing code
■ When not to refactor?
– If rewriting code from scratch
– If too much time is required
FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
Identifying Bad Smells
FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
Identifying Bad Smells
■ Duplicated code
– Extract method: If same code in multiple methods of same class
– Extract class: If same code in multiple classes
– Substitute algorithm: If same functionality at multiple places with different algorithm
■ Long method
– Extract method: If a part of a method can be separated
■ Large class
– Extract class: If a part of a class can be separated
– Extract subclass: If a part of a class can be extended into another class
■ Long parameter list
– Replace Parameter with Method: If parameters value can be obtained by a method
– Extract Parameter Object: If parameters can be grouped into an object
FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
Identifying Bad Smells
■ Temporary field
– Extract class: If all temporary fields can be put together separately
■ Data class
– Encapsulate Field: If class have public fields
– Remove Setting Method: If a field is read-only
■ Refused Bequest
– Push down method, Push down field: If a sibling class can be created to hold unused
■ Comments
– Extract method: If a block of code need a comment to explain what it does
– Rename method: If a method need a comment to explain what it does
FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
Reference
■ Refactoring: Improving the Design of Existing Code by Martin Fowler, Addison-
Wesley, 1999
FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY

More Related Content

What's hot

UML-test Application for Automated Validation of Students’ UML Class Diagram
UML-test Application for Automated Validation of Students’ UML Class DiagramUML-test Application for Automated Validation of Students’ UML Class Diagram
UML-test Application for Automated Validation of Students’ UML Class DiagramPremek Brada
 
Software Cost Estimation Techniques
Software Cost Estimation TechniquesSoftware Cost Estimation Techniques
Software Cost Estimation TechniquesSanthi thi
 
Software engineering
Software engineeringSoftware engineering
Software engineeringh2eEdgar
 
COCOMO Model For Effort Estimation
COCOMO Model For Effort EstimationCOCOMO Model For Effort Estimation
COCOMO Model For Effort Estimationgrandhiprasuna
 
1 modeling concepts
1 modeling concepts1 modeling concepts
1 modeling conceptsMinal Maniar
 
Osama Mohamed Saleh V1
Osama Mohamed Saleh V1Osama Mohamed Saleh V1
Osama Mohamed Saleh V1Osama Mahmed
 
Il product development - 20 01 2011
Il  product development - 20 01 2011Il  product development - 20 01 2011
Il product development - 20 01 2011nakham
 
01 software development life cycle
01 software development life cycle01 software development life cycle
01 software development life cycleAtshushi Takahama
 
software project management Cocomo model
software project management Cocomo modelsoftware project management Cocomo model
software project management Cocomo modelREHMAT ULLAH
 
03 analysis of_requirementsspecification
03 analysis of_requirementsspecification03 analysis of_requirementsspecification
03 analysis of_requirementsspecificationRebecca Jones
 

What's hot (14)

UML-test Application for Automated Validation of Students’ UML Class Diagram
UML-test Application for Automated Validation of Students’ UML Class DiagramUML-test Application for Automated Validation of Students’ UML Class Diagram
UML-test Application for Automated Validation of Students’ UML Class Diagram
 
Unit 1 OOSE
Unit 1 OOSEUnit 1 OOSE
Unit 1 OOSE
 
Software Cost Estimation Techniques
Software Cost Estimation TechniquesSoftware Cost Estimation Techniques
Software Cost Estimation Techniques
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Exam evaluation sytem
Exam  evaluation sytemExam  evaluation sytem
Exam evaluation sytem
 
Spiral Model
Spiral ModelSpiral Model
Spiral Model
 
COCOMO Model For Effort Estimation
COCOMO Model For Effort EstimationCOCOMO Model For Effort Estimation
COCOMO Model For Effort Estimation
 
1 modeling concepts
1 modeling concepts1 modeling concepts
1 modeling concepts
 
Osama Mohamed Saleh V1
Osama Mohamed Saleh V1Osama Mohamed Saleh V1
Osama Mohamed Saleh V1
 
Il product development - 20 01 2011
Il  product development - 20 01 2011Il  product development - 20 01 2011
Il product development - 20 01 2011
 
01 software development life cycle
01 software development life cycle01 software development life cycle
01 software development life cycle
 
software project management Cocomo model
software project management Cocomo modelsoftware project management Cocomo model
software project management Cocomo model
 
03 analysis of_requirementsspecification
03 analysis of_requirementsspecification03 analysis of_requirementsspecification
03 analysis of_requirementsspecification
 

Similar to 7-Refactoring (Object Oriented Software Engineering - BNU Spring 2017)

Computer science curriculum based on Program learning outcomes and objectives
Computer science curriculum based on Program learning outcomes and objectivesComputer science curriculum based on Program learning outcomes and objectives
Computer science curriculum based on Program learning outcomes and objectivesJawad Khan
 
4-Object Oriented Design Heuristics (Object Oriented Software Engineering - B...
4-Object Oriented Design Heuristics (Object Oriented Software Engineering - B...4-Object Oriented Design Heuristics (Object Oriented Software Engineering - B...
4-Object Oriented Design Heuristics (Object Oriented Software Engineering - B...Hafiz Ammar Siddiqui
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy CodeAdam Culp
 
3java Advanced Oop
3java Advanced Oop3java Advanced Oop
3java Advanced OopAdil Jafri
 
Moodle Development Best Pracitces
Moodle Development Best PracitcesMoodle Development Best Pracitces
Moodle Development Best PracitcesJustin Filip
 
Software Engineering Lec 8-design-
Software Engineering Lec 8-design-Software Engineering Lec 8-design-
Software Engineering Lec 8-design-Taymoor Nazmy
 
Putting legacy to REST with middleware
Putting legacy to REST with middlewarePutting legacy to REST with middleware
Putting legacy to REST with middlewareAdam Culp
 
1.01.Introduction.pptx
1.01.Introduction.pptx1.01.Introduction.pptx
1.01.Introduction.pptxBinish Raza
 
Few minutes To better Code - Refactoring
Few minutes To better Code - RefactoringFew minutes To better Code - Refactoring
Few minutes To better Code - RefactoringDiaa Al-Salehi
 
Maintaining and Releasing Open Source Software
Maintaining and Releasing Open Source SoftwareMaintaining and Releasing Open Source Software
Maintaining and Releasing Open Source SoftwareJoel Nothman
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Antonio Peric-Mazar
 
Supporting program comprehension with source code summarization
Supporting program comprehension with source code summarizationSupporting program comprehension with source code summarization
Supporting program comprehension with source code summarizationMasud Rahman
 
Techmindz: Custom Corporate Learning Platform Services in Kochi
Techmindz: Custom Corporate Learning Platform Services in KochiTechmindz: Custom Corporate Learning Platform Services in Kochi
Techmindz: Custom Corporate Learning Platform Services in KochiTechmindz Kochi
 

Similar to 7-Refactoring (Object Oriented Software Engineering - BNU Spring 2017) (20)

OOPSCA1.pptx
OOPSCA1.pptxOOPSCA1.pptx
OOPSCA1.pptx
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
 
Computer science curriculum based on Program learning outcomes and objectives
Computer science curriculum based on Program learning outcomes and objectivesComputer science curriculum based on Program learning outcomes and objectives
Computer science curriculum based on Program learning outcomes and objectives
 
4-Object Oriented Design Heuristics (Object Oriented Software Engineering - B...
4-Object Oriented Design Heuristics (Object Oriented Software Engineering - B...4-Object Oriented Design Heuristics (Object Oriented Software Engineering - B...
4-Object Oriented Design Heuristics (Object Oriented Software Engineering - B...
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
3java Advanced Oop
3java Advanced Oop3java Advanced Oop
3java Advanced Oop
 
L12 GRASP
L12 GRASPL12 GRASP
L12 GRASP
 
Moodle Development Best Pracitces
Moodle Development Best PracitcesMoodle Development Best Pracitces
Moodle Development Best Pracitces
 
Software Engineering Lec 8-design-
Software Engineering Lec 8-design-Software Engineering Lec 8-design-
Software Engineering Lec 8-design-
 
Oop principles
Oop principlesOop principles
Oop principles
 
Putting legacy to REST with middleware
Putting legacy to REST with middlewarePutting legacy to REST with middleware
Putting legacy to REST with middleware
 
1.01.Introduction.pptx
1.01.Introduction.pptx1.01.Introduction.pptx
1.01.Introduction.pptx
 
Few minutes To better Code - Refactoring
Few minutes To better Code - RefactoringFew minutes To better Code - Refactoring
Few minutes To better Code - Refactoring
 
Maintaining and Releasing Open Source Software
Maintaining and Releasing Open Source SoftwareMaintaining and Releasing Open Source Software
Maintaining and Releasing Open Source Software
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
 
Supporting program comprehension with source code summarization
Supporting program comprehension with source code summarizationSupporting program comprehension with source code summarization
Supporting program comprehension with source code summarization
 
SRMS-FINAL 3.pptx
SRMS-FINAL 3.pptxSRMS-FINAL 3.pptx
SRMS-FINAL 3.pptx
 
Techmindz: Custom Corporate Learning Platform Services in Kochi
Techmindz: Custom Corporate Learning Platform Services in KochiTechmindz: Custom Corporate Learning Platform Services in Kochi
Techmindz: Custom Corporate Learning Platform Services in Kochi
 
DITEC - Software Engineering
DITEC - Software EngineeringDITEC - Software Engineering
DITEC - Software Engineering
 

More from Hafiz Ammar Siddiqui

4-Game Physics (Game Design and Development)
4-Game Physics (Game Design and Development)4-Game Physics (Game Design and Development)
4-Game Physics (Game Design and Development)Hafiz Ammar Siddiqui
 
3-Game Graphics (Game Design and Development)
3-Game Graphics (Game Design and Development)3-Game Graphics (Game Design and Development)
3-Game Graphics (Game Design and Development)Hafiz Ammar Siddiqui
 
2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)Hafiz Ammar Siddiqui
 
1-Introduction (Game Design and Development)
1-Introduction (Game Design and Development)1-Introduction (Game Design and Development)
1-Introduction (Game Design and Development)Hafiz Ammar Siddiqui
 
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...Hafiz Ammar Siddiqui
 
9-Game Design (Game Development - UMT Spring 2017/2018)
9-Game Design (Game Development - UMT Spring 2017/2018)9-Game Design (Game Development - UMT Spring 2017/2018)
9-Game Design (Game Development - UMT Spring 2017/2018)Hafiz Ammar Siddiqui
 
6-Animation in Game (Game Development - UMT Spring 2017/2018)
6-Animation in Game (Game Development - UMT Spring 2017/2018)6-Animation in Game (Game Development - UMT Spring 2017/2018)
6-Animation in Game (Game Development - UMT Spring 2017/2018)Hafiz Ammar Siddiqui
 
3-Graphics in Game (Game Development - UMT Spring 2017/2018)
3-Graphics in Game (Game Development - UMT Spring 2017/2018)3-Graphics in Game (Game Development - UMT Spring 2017/2018)
3-Graphics in Game (Game Development - UMT Spring 2017/2018)Hafiz Ammar Siddiqui
 
1-Introduction (Game Development - UMT Spring 2017/2018)
1-Introduction (Game Development - UMT Spring 2017/2018)1-Introduction (Game Development - UMT Spring 2017/2018)
1-Introduction (Game Development - UMT Spring 2017/2018)Hafiz Ammar Siddiqui
 

More from Hafiz Ammar Siddiqui (9)

4-Game Physics (Game Design and Development)
4-Game Physics (Game Design and Development)4-Game Physics (Game Design and Development)
4-Game Physics (Game Design and Development)
 
3-Game Graphics (Game Design and Development)
3-Game Graphics (Game Design and Development)3-Game Graphics (Game Design and Development)
3-Game Graphics (Game Design and Development)
 
2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)2-Game Design (Game Design and Development)
2-Game Design (Game Design and Development)
 
1-Introduction (Game Design and Development)
1-Introduction (Game Design and Development)1-Introduction (Game Design and Development)
1-Introduction (Game Design and Development)
 
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
10-Software Project Management (Object Oriented Software Engineering - BNU Sp...
 
9-Game Design (Game Development - UMT Spring 2017/2018)
9-Game Design (Game Development - UMT Spring 2017/2018)9-Game Design (Game Development - UMT Spring 2017/2018)
9-Game Design (Game Development - UMT Spring 2017/2018)
 
6-Animation in Game (Game Development - UMT Spring 2017/2018)
6-Animation in Game (Game Development - UMT Spring 2017/2018)6-Animation in Game (Game Development - UMT Spring 2017/2018)
6-Animation in Game (Game Development - UMT Spring 2017/2018)
 
3-Graphics in Game (Game Development - UMT Spring 2017/2018)
3-Graphics in Game (Game Development - UMT Spring 2017/2018)3-Graphics in Game (Game Development - UMT Spring 2017/2018)
3-Graphics in Game (Game Development - UMT Spring 2017/2018)
 
1-Introduction (Game Development - UMT Spring 2017/2018)
1-Introduction (Game Development - UMT Spring 2017/2018)1-Introduction (Game Development - UMT Spring 2017/2018)
1-Introduction (Game Development - UMT Spring 2017/2018)
 

Recently uploaded

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 

Recently uploaded (20)

Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 

7-Refactoring (Object Oriented Software Engineering - BNU Spring 2017)

  • 1. Refactoring FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
  • 2. Refactoring ■ Process of changing a software system in such a way that it does not change its external behavior but improves its internal structure ■ Restructure a software without changing its observable behavior ■ Improving the code of a software without adding new functionality or changing any existing functionality ■ Process of cleaning up the code of a software without changing its output – Enhances the readability of code – Reduces the complexity in code – Improves the maintainabilityof code – Provides the extensibility for code FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
  • 3. Principles in Refactoring FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
  • 4. Principles in Refactoring ■ Why refactor? – Improves the design of software – Makes software easier to understand – Helps in finding bugs – Helps in programming faster ■ When to refactor? – On adding a functionality – On fixing an error – On reviewing code ■ When not to refactor? – If rewriting code from scratch – If too much time is required FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
  • 5. Identifying Bad Smells FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
  • 6. Identifying Bad Smells ■ Duplicated code – Extract method: If same code in multiple methods of same class – Extract class: If same code in multiple classes – Substitute algorithm: If same functionality at multiple places with different algorithm ■ Long method – Extract method: If a part of a method can be separated ■ Large class – Extract class: If a part of a class can be separated – Extract subclass: If a part of a class can be extended into another class ■ Long parameter list – Replace Parameter with Method: If parameters value can be obtained by a method – Extract Parameter Object: If parameters can be grouped into an object FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
  • 7. Identifying Bad Smells ■ Temporary field – Extract class: If all temporary fields can be put together separately ■ Data class – Encapsulate Field: If class have public fields – Remove Setting Method: If a field is read-only ■ Refused Bequest – Push down method, Push down field: If a sibling class can be created to hold unused ■ Comments – Extract method: If a block of code need a comment to explain what it does – Rename method: If a method need a comment to explain what it does FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY
  • 8. Reference ■ Refactoring: Improving the Design of Existing Code by Martin Fowler, Addison- Wesley, 1999 FROM: HAFIZ AMMAR SIDDIQUI – COURSE: OBJECT ORIENTED SOFTWARE ENGINEERING – INSTITUTE: BEACONHOUSE NATIONAL UNIVERSITY