SlideShare uma empresa Scribd logo
1 de 15
AntiPatterns & CodeSmells
Common practices to improve code quality
Anti patterns
Counterpart to design patterns
What is an Anti pattern?
 The result of a developer not knowing any better, not
having sufficient knowledge or experience in solving
a particular type of problem.
 Or a developer has applied a perfectly good pattern
in the wrong context.
The Blob
 Also known as: «The God Class»
 Root Causes: Sloth, Haste
 Anecdotal Evidence: “This is the class that is really
the heart of our architecture:”
 Refactoring: Refactoring of Responsibilities
Lava Flow
 Also known as: Dead Code
 Root Causes: Greed, Sloth
 Anecdotal Evidence: “Oh that! Well Ray and Emil (they’re no
longer with the company) wrote that routine back when Jim (who left
last month) was trying a workaround for Irene’s input processing
code (she’s in another department now, too). I don’t think it’s used
anywhere now, but I’m not really sure.
 Refactoring: Architectural Configuration
Management
Golden Hammer
 Definition: A Golden Hammer is a familiar
technology or concept applied obsessively to many
software problems.
 Root Causes: Ignorance, Pride, Narrow-
Mindedness
 Anecdotal Evidence: “I have a hammer and
everything is a nail.”, “Our database is our
architecture.”
 Refactoring: Expand your horizons
Code smells
Give you a hint when something is wrong
What is a Code smell?
 If it stinks, change it.
 Helps you to spot a code portion which should be
refactored.
 Tries to explain not only you should refactor, but why
you should do so.
Duplicated code
Definition
 (Nearly) the same code
structure in more than
one place
Refactorings
 Extract Method
 Extract Class
 Pull Up Field
 Template Method
Shotgun Surgery
Definition
 Every time you make a
kind of change, you
have to make a lot of
little changes to a lot of
different classes
Refactorings
 Move Method
 Move Field
 Inline Class
Switch Statements
Definition
 The problem with switch
statements is essentially
that of duplication.
 Often you find the same
switch statement over
and over again.
 If you add a new clause
to the switch, you have
to find all the other
switches and change
them.
Refactorings
 Replace with Strategy
 Replace with State
 Replace Conditional
with Polymorphism
Data class
Definition
 Class that has only
fields, no methods
operating on these
fields.
 Contains fields which
are manipulated from
other classes
Refactorings
 Encapsulate Fields
 Encapsulate Collection
 Move Method
 Extract Method
Overview
 Bad Smells in Code
 Bad Smells in Code
 Duplicated Code
 Long Method
 Large Class
 Long Parameter List
 Divergent Change
 Shotgun Surgery
 Feature Envy
 Data Clumps
 Primitive Obsession
 Switch Statements
 Parallel Inheritance Hierarchies
 Lazy Class
 Speculative Generality
 Temporary Field
 Message Chains
 Middle Man
 Inappropriate Intimacy
 Alternative Classes with Different Interfaces
 Incomplete Library Class
 Data Class
 Refused Bequest
 Comments
 Development AntiPatterns
 The Blob
 Continuous Obsolescence
 Lava Flow
 Ambiguous Viewpoint
 Functional Decomposition
 Poltergeists
 Boat Anchor
 Golden Hammer
 Dead End
 Spaghetti Code
 Input Kludge
 Walking through a Minefield
 Cut-And-Paste Programming
 Mushroom Management
Refactoring – Improving the design of
existing code
 Martin Fowler (1963)
 Author and international speaker
on software development,
specialized in OO design.
 Kent Beck (1961)
 Software engineer and the
creator of Extreme Programming
and TDD software development
methodologies.
 Publication date: 28 Jun
1999
 ISBN-13: 978-0201485677
Resources
www.SourceMaking.com

Mais conteúdo relacionado

Mais procurados

Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBADCPS
 
Ibm portfolio piece
Ibm portfolio pieceIbm portfolio piece
Ibm portfolio pieceColson Rice
 
Bn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netBn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netconline training
 
Oop c sharp_part_1
Oop c sharp_part_1Oop c sharp_part_1
Oop c sharp_part_1shivaksn
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.netSaad Wazir
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the informationToushik Paul
 
NET Event - Migrating WinForm
NET Event - Migrating WinFormNET Event - Migrating WinForm
NET Event - Migrating WinFormRaffaele Garofalo
 
Visual programming lecture
Visual programming lecture Visual programming lecture
Visual programming lecture AqsaHayat3
 
Webinar: Microsoft .NET Framework : An IntelliSense Way of Web Development
Webinar: Microsoft .NET Framework : An IntelliSense Way of Web DevelopmentWebinar: Microsoft .NET Framework : An IntelliSense Way of Web Development
Webinar: Microsoft .NET Framework : An IntelliSense Way of Web DevelopmentEdureka!
 
Our law android application
Our law android applicationOur law android application
Our law android applicationRasel Khan
 
Whats New In Visual Studio 2010
Whats New In Visual Studio 2010Whats New In Visual Studio 2010
Whats New In Visual Studio 2010Daniel Egan
 
Introduction to visual basic
Introduction to visual basicIntroduction to visual basic
Introduction to visual basicManav Khandelwal
 

Mais procurados (20)

Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBA
 
Ibm portfolio piece
Ibm portfolio pieceIbm portfolio piece
Ibm portfolio piece
 
Vb.net ide
Vb.net ideVb.net ide
Vb.net ide
 
Bn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot netBn1001 demo ppt advance dot net
Bn1001 demo ppt advance dot net
 
C# p1
C# p1C# p1
C# p1
 
Oop c sharp_part_1
Oop c sharp_part_1Oop c sharp_part_1
Oop c sharp_part_1
 
Sreeraj_Resume
Sreeraj_ResumeSreeraj_Resume
Sreeraj_Resume
 
Visual Studio
Visual StudioVisual Studio
Visual Studio
 
Visual Studio 2012 introduction
Visual Studio  2012 introductionVisual Studio  2012 introduction
Visual Studio 2012 introduction
 
Developing Facebook Application
Developing Facebook ApplicationDeveloping Facebook Application
Developing Facebook Application
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the information
 
NET Event - Migrating WinForm
NET Event - Migrating WinFormNET Event - Migrating WinForm
NET Event - Migrating WinForm
 
Visual programming lecture
Visual programming lecture Visual programming lecture
Visual programming lecture
 
Using Vba Excel
Using Vba ExcelUsing Vba Excel
Using Vba Excel
 
Webinar: Microsoft .NET Framework : An IntelliSense Way of Web Development
Webinar: Microsoft .NET Framework : An IntelliSense Way of Web DevelopmentWebinar: Microsoft .NET Framework : An IntelliSense Way of Web Development
Webinar: Microsoft .NET Framework : An IntelliSense Way of Web Development
 
Our law android application
Our law android applicationOur law android application
Our law android application
 
Whats New In Visual Studio 2010
Whats New In Visual Studio 2010Whats New In Visual Studio 2010
Whats New In Visual Studio 2010
 
Introduction to visual basic
Introduction to visual basicIntroduction to visual basic
Introduction to visual basic
 
Salesforce Spring 20 Highlights
Salesforce Spring 20 HighlightsSalesforce Spring 20 Highlights
Salesforce Spring 20 Highlights
 

Destaque

Anemic Domain Model - антипаттерн или SOLID?
Anemic Domain Model - антипаттерн или SOLID?Anemic Domain Model - антипаттерн или SOLID?
Anemic Domain Model - антипаттерн или SOLID?GoSharp
 
Software Accessibility Siddhesh
Software Accessibility SiddheshSoftware Accessibility Siddhesh
Software Accessibility SiddheshSiddhesh Bhobe
 
Software Architecture Erosion and Modernization
Software Architecture Erosion and ModernizationSoftware Architecture Erosion and Modernization
Software Architecture Erosion and Modernizationbmerkle
 
eMee at HR Tech Europe, 26 March, London
eMee at HR Tech Europe, 26 March, LondoneMee at HR Tech Europe, 26 March, London
eMee at HR Tech Europe, 26 March, LondonSiddhesh Bhobe
 
Refactoring for Software Architecture Smells - International Workshop on Refa...
Refactoring for Software Architecture Smells - International Workshop on Refa...Refactoring for Software Architecture Smells - International Workshop on Refa...
Refactoring for Software Architecture Smells - International Workshop on Refa...Ganesh Samarthyam
 
Lead Allocation System's Attribute Driven Design (ADD)
Lead Allocation System's Attribute Driven Design (ADD)Lead Allocation System's Attribute Driven Design (ADD)
Lead Allocation System's Attribute Driven Design (ADD)Amin Bandeali
 
Anti Patterns Siddhesh Lecture2 Of3
Anti Patterns Siddhesh Lecture2 Of3Anti Patterns Siddhesh Lecture2 Of3
Anti Patterns Siddhesh Lecture2 Of3Siddhesh Bhobe
 
Anti Patterns Siddhesh Lecture1 Of3
Anti Patterns Siddhesh Lecture1 Of3Anti Patterns Siddhesh Lecture1 Of3
Anti Patterns Siddhesh Lecture1 Of3Siddhesh Bhobe
 
Anti Patterns Siddhesh Lecture3 Of3
Anti Patterns Siddhesh Lecture3 Of3Anti Patterns Siddhesh Lecture3 Of3
Anti Patterns Siddhesh Lecture3 Of3Siddhesh Bhobe
 
Software Architecture Anti-Patterns
Software Architecture Anti-PatternsSoftware Architecture Anti-Patterns
Software Architecture Anti-PatternsEduards Sizovs
 
Lead Allocation System - Attribute Driven Design (ADD)
Lead Allocation System - Attribute Driven Design (ADD)Lead Allocation System - Attribute Driven Design (ADD)
Lead Allocation System - Attribute Driven Design (ADD)Amin Bandeali
 
Industry expectations from new recruits
Industry expectations from new recruitsIndustry expectations from new recruits
Industry expectations from new recruitsSiddhesh Bhobe
 
The eMee Value Proposition
The eMee Value PropositionThe eMee Value Proposition
The eMee Value PropositionSiddhesh Bhobe
 
Attribute Driven Styles: The Good, the Bad, and the Unknown (SassConf 2015 Di...
Attribute Driven Styles: The Good, the Bad, and the Unknown (SassConf 2015 Di...Attribute Driven Styles: The Good, the Bad, and the Unknown (SassConf 2015 Di...
Attribute Driven Styles: The Good, the Bad, and the Unknown (SassConf 2015 Di...Jonathan Cutrell
 
Software Design - Architectural Kata
Software Design - Architectural KataSoftware Design - Architectural Kata
Software Design - Architectural KataDeniz Yavaş
 
Api anti patterns
Api anti patternsApi anti patterns
Api anti patternsMike Pearce
 
Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5Sudarshan Dhondaley
 
Bangalore Container Conference 2017 - Poster
Bangalore Container Conference 2017 - PosterBangalore Container Conference 2017 - Poster
Bangalore Container Conference 2017 - PosterGanesh Samarthyam
 

Destaque (20)

Anemic Domain Model - антипаттерн или SOLID?
Anemic Domain Model - антипаттерн или SOLID?Anemic Domain Model - антипаттерн или SOLID?
Anemic Domain Model - антипаттерн или SOLID?
 
Software Accessibility Siddhesh
Software Accessibility SiddheshSoftware Accessibility Siddhesh
Software Accessibility Siddhesh
 
Software Architecture Erosion and Modernization
Software Architecture Erosion and ModernizationSoftware Architecture Erosion and Modernization
Software Architecture Erosion and Modernization
 
eMee at HR Tech Europe, 26 March, London
eMee at HR Tech Europe, 26 March, LondoneMee at HR Tech Europe, 26 March, London
eMee at HR Tech Europe, 26 March, London
 
Refactoring for Software Architecture Smells - International Workshop on Refa...
Refactoring for Software Architecture Smells - International Workshop on Refa...Refactoring for Software Architecture Smells - International Workshop on Refa...
Refactoring for Software Architecture Smells - International Workshop on Refa...
 
Lead Allocation System's Attribute Driven Design (ADD)
Lead Allocation System's Attribute Driven Design (ADD)Lead Allocation System's Attribute Driven Design (ADD)
Lead Allocation System's Attribute Driven Design (ADD)
 
Anti Patterns Siddhesh Lecture2 Of3
Anti Patterns Siddhesh Lecture2 Of3Anti Patterns Siddhesh Lecture2 Of3
Anti Patterns Siddhesh Lecture2 Of3
 
Anti Patterns Siddhesh Lecture1 Of3
Anti Patterns Siddhesh Lecture1 Of3Anti Patterns Siddhesh Lecture1 Of3
Anti Patterns Siddhesh Lecture1 Of3
 
Anti Patterns Siddhesh Lecture3 Of3
Anti Patterns Siddhesh Lecture3 Of3Anti Patterns Siddhesh Lecture3 Of3
Anti Patterns Siddhesh Lecture3 Of3
 
Anti Patterns
Anti PatternsAnti Patterns
Anti Patterns
 
Software Architecture Anti-Patterns
Software Architecture Anti-PatternsSoftware Architecture Anti-Patterns
Software Architecture Anti-Patterns
 
Anti patterns part 1
Anti patterns part 1Anti patterns part 1
Anti patterns part 1
 
Lead Allocation System - Attribute Driven Design (ADD)
Lead Allocation System - Attribute Driven Design (ADD)Lead Allocation System - Attribute Driven Design (ADD)
Lead Allocation System - Attribute Driven Design (ADD)
 
Industry expectations from new recruits
Industry expectations from new recruitsIndustry expectations from new recruits
Industry expectations from new recruits
 
The eMee Value Proposition
The eMee Value PropositionThe eMee Value Proposition
The eMee Value Proposition
 
Attribute Driven Styles: The Good, the Bad, and the Unknown (SassConf 2015 Di...
Attribute Driven Styles: The Good, the Bad, and the Unknown (SassConf 2015 Di...Attribute Driven Styles: The Good, the Bad, and the Unknown (SassConf 2015 Di...
Attribute Driven Styles: The Good, the Bad, and the Unknown (SassConf 2015 Di...
 
Software Design - Architectural Kata
Software Design - Architectural KataSoftware Design - Architectural Kata
Software Design - Architectural Kata
 
Api anti patterns
Api anti patternsApi anti patterns
Api anti patterns
 
Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5Designing and documenting software architecture unit 5
Designing and documenting software architecture unit 5
 
Bangalore Container Conference 2017 - Poster
Bangalore Container Conference 2017 - PosterBangalore Container Conference 2017 - Poster
Bangalore Container Conference 2017 - Poster
 

Semelhante a Introduction to AntiPatterns & CodeSmells

Getting Unstuck: Working with Legacy Code and Data
Getting Unstuck: Working with Legacy Code and DataGetting Unstuck: Working with Legacy Code and Data
Getting Unstuck: Working with Legacy Code and DataCory Foy
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 
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
 
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible MistakesRoy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible MistakesRoy Osherove
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionDionatan default
 
Design patterns - The Good, the Bad, and the Anti-Pattern
Design patterns -  The Good, the Bad, and the Anti-PatternDesign patterns -  The Good, the Bad, and the Anti-Pattern
Design patterns - The Good, the Bad, and the Anti-PatternBarry O Sullivan
 
Framework Design Guidelines
Framework Design GuidelinesFramework Design Guidelines
Framework Design GuidelinesMohamed Meligy
 
Bade Smells in Code
Bade Smells in CodeBade Smells in Code
Bade Smells in CodeWill Shen
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldSaurabh Moody
 
Clean Code summary
Clean Code summaryClean Code summary
Clean Code summaryJan de Vries
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestableRoyKlein
 
Engaging the Xen Developer Comminity
Engaging the Xen Developer ComminityEngaging the Xen Developer Comminity
Engaging the Xen Developer ComminityThe Linux Foundation
 

Semelhante a Introduction to AntiPatterns & CodeSmells (20)

Refactoring
RefactoringRefactoring
Refactoring
 
Getting Unstuck: Working with Legacy Code and Data
Getting Unstuck: Working with Legacy Code and DataGetting Unstuck: Working with Legacy Code and Data
Getting Unstuck: Working with Legacy Code and Data
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
 
The Modlet Pattern
The Modlet PatternThe Modlet Pattern
The Modlet Pattern
 
Code smell overview
Code smell overviewCode smell overview
Code smell overview
 
Code Smells
Code SmellsCode Smells
Code Smells
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Code review
Code reviewCode review
Code review
 
Few minutes To better Code - Refactoring
Few minutes To better Code - RefactoringFew minutes To better Code - Refactoring
Few minutes To better Code - Refactoring
 
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible MistakesRoy Osherove on Unit Testing Good Practices and Horrible Mistakes
Roy Osherove on Unit Testing Good Practices and Horrible Mistakes
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
Design patterns - The Good, the Bad, and the Anti-Pattern
Design patterns -  The Good, the Bad, and the Anti-PatternDesign patterns -  The Good, the Bad, and the Anti-Pattern
Design patterns - The Good, the Bad, and the Anti-Pattern
 
Framework Design Guidelines
Framework Design GuidelinesFramework Design Guidelines
Framework Design Guidelines
 
Bade Smells in Code
Bade Smells in CodeBade Smells in Code
Bade Smells in Code
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
 
Clean Code summary
Clean Code summaryClean Code summary
Clean Code summary
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
 
Testing the untestable
Testing the untestableTesting the untestable
Testing the untestable
 
Engaging the Xen Developer Comminity
Engaging the Xen Developer ComminityEngaging the Xen Developer Comminity
Engaging the Xen Developer Comminity
 

Último

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 

Último (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 

Introduction to AntiPatterns & CodeSmells

  • 1. AntiPatterns & CodeSmells Common practices to improve code quality
  • 3. What is an Anti pattern?  The result of a developer not knowing any better, not having sufficient knowledge or experience in solving a particular type of problem.  Or a developer has applied a perfectly good pattern in the wrong context.
  • 4. The Blob  Also known as: «The God Class»  Root Causes: Sloth, Haste  Anecdotal Evidence: “This is the class that is really the heart of our architecture:”  Refactoring: Refactoring of Responsibilities
  • 5. Lava Flow  Also known as: Dead Code  Root Causes: Greed, Sloth  Anecdotal Evidence: “Oh that! Well Ray and Emil (they’re no longer with the company) wrote that routine back when Jim (who left last month) was trying a workaround for Irene’s input processing code (she’s in another department now, too). I don’t think it’s used anywhere now, but I’m not really sure.  Refactoring: Architectural Configuration Management
  • 6. Golden Hammer  Definition: A Golden Hammer is a familiar technology or concept applied obsessively to many software problems.  Root Causes: Ignorance, Pride, Narrow- Mindedness  Anecdotal Evidence: “I have a hammer and everything is a nail.”, “Our database is our architecture.”  Refactoring: Expand your horizons
  • 7. Code smells Give you a hint when something is wrong
  • 8. What is a Code smell?  If it stinks, change it.  Helps you to spot a code portion which should be refactored.  Tries to explain not only you should refactor, but why you should do so.
  • 9. Duplicated code Definition  (Nearly) the same code structure in more than one place Refactorings  Extract Method  Extract Class  Pull Up Field  Template Method
  • 10. Shotgun Surgery Definition  Every time you make a kind of change, you have to make a lot of little changes to a lot of different classes Refactorings  Move Method  Move Field  Inline Class
  • 11. Switch Statements Definition  The problem with switch statements is essentially that of duplication.  Often you find the same switch statement over and over again.  If you add a new clause to the switch, you have to find all the other switches and change them. Refactorings  Replace with Strategy  Replace with State  Replace Conditional with Polymorphism
  • 12. Data class Definition  Class that has only fields, no methods operating on these fields.  Contains fields which are manipulated from other classes Refactorings  Encapsulate Fields  Encapsulate Collection  Move Method  Extract Method
  • 13. Overview  Bad Smells in Code  Bad Smells in Code  Duplicated Code  Long Method  Large Class  Long Parameter List  Divergent Change  Shotgun Surgery  Feature Envy  Data Clumps  Primitive Obsession  Switch Statements  Parallel Inheritance Hierarchies  Lazy Class  Speculative Generality  Temporary Field  Message Chains  Middle Man  Inappropriate Intimacy  Alternative Classes with Different Interfaces  Incomplete Library Class  Data Class  Refused Bequest  Comments  Development AntiPatterns  The Blob  Continuous Obsolescence  Lava Flow  Ambiguous Viewpoint  Functional Decomposition  Poltergeists  Boat Anchor  Golden Hammer  Dead End  Spaghetti Code  Input Kludge  Walking through a Minefield  Cut-And-Paste Programming  Mushroom Management
  • 14. Refactoring – Improving the design of existing code  Martin Fowler (1963)  Author and international speaker on software development, specialized in OO design.  Kent Beck (1961)  Software engineer and the creator of Extreme Programming and TDD software development methodologies.  Publication date: 28 Jun 1999  ISBN-13: 978-0201485677