SlideShare a Scribd company logo
1 of 55
Software Craftsmanship
Code Smells
Software Craftsmanship Manifesto
“Not only working software, but also well-
crafted software
Not only responding to change, but also steadily
adding value
Not only individuals and interactions, but also a
community of professionals
Not only customer collaboration, but also
productive partnerships”
Technical Debt
Software Finance
Skipping (or deferring) design Borrowing money
Refactoring (i.e. behavior-preserving
design improvements)
Repaying principal
Slower development due to code
smells
Paying interest
Code Smells
• Lost Intent
• Inefficient Name
• Duplicated Code
• Deodorant Comment
• Long Method
• Large Class
• Lazy Class
More…
Lost Intent
Just as a traffic sign may be obscured by shrubs, Code that doesn't easily communicate
it's author's intention is hazardous: hard to understand, extend and modify.
Lost Intent
Intention-Revealing Code Lost Intent
The purpose of the code is clear.
Low-level or complex logic obscures
the code's purpose.
You can easily find the code you seek.
The location of code makes little
sense.
Every step of an algorithm is clearly
defined.
The steps of the algorithm are
blended together.
Lost Intent
Inefficient Name
Where The Streets Have No Name
Inefficient Name
tmp = finder.fetch("0182901");
Account theAccount = finder.fetch(transaction.getSource());
account = finder.fetch( new StateMatcher("VA") );
for(Account item : finder.fetchAll()) { … }
getDrctn()
getDir()
getDirection()
These are five lines chosen at random from a class.
Each is grabbing a fetch result and putting it in a variable of type Account.
Duplicated Code
If you see the same code structure in more than one place, you can be sure that your program
will be better if you find a way to unify them.
— Refactoring[page 76], Martin Fowler and Kent Beck
Duplicated Code
Deodorant Comment
Comments often are used as a deodorant.
— Refactoring [page 87], Martin Fowler and Kent Beck
Deodorant Comment
Comment Guidelines
• Whenever possible make your code express
the intent of the comment and remove the
comment.
• Comments are to provide intent that
is not expressible in code.
• Any comment that duplicates what the code
says should be deleted.
Long Method
A long method is too much to digest
Long Method
Large Class
Take on too many responsibilities
Large Class
WebServicesProviderContoller
• performValidationCB()
• executeBusinessProcessCB()
Lazy Class
A lazy class isn't doing enough to justify its existence.
Lazy Class
Lazy Class
Employee constructor
.
Passing Jobs in
Employee
constructor.
Oddball Solution
When a problem is solved one way throughout a system and the same problem is
solved another way in the same system, one of the solutions is the oddball or
inconsistent solution.
Oddball Solution
Primitive Obsession
Primitive Obsession exists when code solves a problem using a tool that's too simplistic.
Primitive Obsession
Switch Statement
Most times you see a switch statement you should consider polymorphism.
— Refactoring, Martin Fowler and Kent Beck (page 82).
Switch Statement
Move each leg of the conditional to an overriding method in a subclass. Make the original
method abstract.
Switch Statement
• Not every occurrence of a switch statement
(or if...else if...else if... statements) should be
replaced with a polymorphic solution.
Speculative Generality
You get this smell when people say "Oh, I think we will need the ability to do that someday"
and thus want all sorts of hooks and special cases to handle things that aren't required. —
Refactoring, Martin Fowler and Kent Beck (page 83).
Speculative Generality
Long Parameter List
Methods that take too many parameters produce client code that is awkward and
difficult to work with.
Long Parameter List
user = userManager.create(USER_NAME, group, USER_NAME, “test",
USER_NAME, LANGUAGE, false, false, new Date(), "blah", new Date());
Conditional Complexity
Conditional logic is innocent in its infancy, when it is simple to understand and contained
within a few lines of code. Unfortunately, it rarely ages well.
— Joshua Kerievsky, Refactoring to Patterns, page 41.
Conditional Complexity
Combinatorial Explosion
When new combinations of data or behavior further bloat an already bloated design, you've got
a Combinatorial Explosion smell.
Combinatorial Explosion
Alternative Classes With Different
Interfaces
This subtle smell results when differences in the interfaces of similar classes leads to
duplicated code.
Alternative Classes With Different
Interfaces
Inappropriate Intimacy
Sometimes classes become far too intimate and spend too much time delving in each others'
private parts.
— Refactoring [page 85], Fowler and Beck
Inappropriate Intimacy
Indecent Exposure
We don't normally expose wires inside a wall or ceiling.
Indecent Exposure
Refused Bequest
Subclasses get to inherit the methods and data of their parents. But what if they don't
want or need what they are given? — Refactoring[page 87], Martin Fowler and Kent Beck
Refused Bequest
Black Sheep
Black Sheep
Solution Sprawl
When code and/or data used to perform a responsibility becomes sprawled across numerous
classes, Solution Sprawl is in the air.
— Joshua Kerievsky, Refactoring to Patterns, page 43.
Solution Sprawl
Feature Envy
Feature Envy
Temporary Field
An object's field (a.k.a. instance variable) should have meaning during the full lifetime
of the object.
Temporary Field
Side Effect
Side Effect
References
• Refactoring: Improving the Design of Existing
Code by Martin Fowler
• Refactoring to Patterns by Joshua Kerievsky.
• https://elearning.industriallogic.com/gh/subm
it?Action=AlbumContentsAction&album=reco
gnizingSmells&devLanguage=Java

More Related Content

What's hot

Refactoring for Software Design Smells - 1 day Workshop
Refactoring for Software Design Smells - 1 day Workshop Refactoring for Software Design Smells - 1 day Workshop
Refactoring for Software Design Smells - 1 day Workshop Ganesh Samarthyam
 
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
 
Software Craftsmanship - Code Smells - Dispensables
Software Craftsmanship - Code Smells - DispensablesSoftware Craftsmanship - Code Smells - Dispensables
Software Craftsmanship - Code Smells - DispensablesRajat Singla
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in JavaIonut Bilica
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable codeGeshan Manandhar
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slidesthinkddd
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionsaber tabatabaee
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternMudasir Qazi
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignVictor Rentea
 
Clean Code Principles
Clean Code PrinciplesClean Code Principles
Clean Code PrinciplesYeurDreamin'
 

What's hot (20)

Refactoring for Software Design Smells - 1 day Workshop
Refactoring for Software Design Smells - 1 day Workshop Refactoring for Software Design Smells - 1 day Workshop
Refactoring for Software Design Smells - 1 day Workshop
 
Refactoring
RefactoringRefactoring
Refactoring
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Clean code
Clean codeClean code
Clean code
 
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
 
Clean code slide
Clean code slideClean code slide
Clean code slide
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
 
Software Craftsmanship - Code Smells - Dispensables
Software Craftsmanship - Code Smells - DispensablesSoftware Craftsmanship - Code Smells - Dispensables
Software Craftsmanship - Code Smells - Dispensables
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
 
Bad smells no código
Bad smells no códigoBad smells no código
Bad smells no código
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable code
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable Design
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
 
Clean Code Principles
Clean Code PrinciplesClean Code Principles
Clean Code Principles
 

Similar to Code Smells

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
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven designRick van der Arend
 
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
 
Day2 - Refactoring (Lecture SS 2015)
Day2 - Refactoring (Lecture SS 2015)Day2 - Refactoring (Lecture SS 2015)
Day2 - Refactoring (Lecture SS 2015)wolframkriesing
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Codeeddiehaber
 
Generic or specific? Making sensible software design decisions
 Generic or specific? Making sensible software design decisions  Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions Bert Jan Schrijver
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions Bert Jan Schrijver
 
Code smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsCode smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsClint Edmonson
 
Introduction to AntiPatterns & CodeSmells
Introduction to AntiPatterns & CodeSmellsIntroduction to AntiPatterns & CodeSmells
Introduction to AntiPatterns & CodeSmellsClaudio Bernasconi
 
JUG CH December 2022 - Generic or specific?
JUG CH December 2022 - Generic or specific?JUG CH December 2022 - Generic or specific?
JUG CH December 2022 - Generic or specific?Bert Jan Schrijver
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2Ankit Dubey
 
Planning JavaScript and Ajax for larger teams
Planning JavaScript and Ajax for larger teamsPlanning JavaScript and Ajax for larger teams
Planning JavaScript and Ajax for larger teamsChristian Heilmann
 
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkTaming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkJoseph Yoder
 

Similar to Code Smells (20)

Refactoring 2 The Max
Refactoring 2 The MaxRefactoring 2 The Max
Refactoring 2 The Max
 
Code quality
Code quality Code quality
Code quality
 
Few minutes To better Code - Refactoring
Few minutes To better Code - RefactoringFew minutes To better Code - Refactoring
Few minutes To better Code - Refactoring
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
 
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
 
DDD In Agile
DDD In Agile   DDD In Agile
DDD In Agile
 
Day2 - Refactoring (Lecture SS 2015)
Day2 - Refactoring (Lecture SS 2015)Day2 - Refactoring (Lecture SS 2015)
Day2 - Refactoring (Lecture SS 2015)
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 
Refactoring
RefactoringRefactoring
Refactoring
 
Generic or specific? Making sensible software design decisions
 Generic or specific? Making sensible software design decisions  Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Writing Quality Code
Writing Quality CodeWriting Quality Code
Writing Quality Code
 
Code smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsCode smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software Odors
 
Introduction to AntiPatterns & CodeSmells
Introduction to AntiPatterns & CodeSmellsIntroduction to AntiPatterns & CodeSmells
Introduction to AntiPatterns & CodeSmells
 
JUG CH December 2022 - Generic or specific?
JUG CH December 2022 - Generic or specific?JUG CH December 2022 - Generic or specific?
JUG CH December 2022 - Generic or specific?
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
 
Code Quality
Code QualityCode Quality
Code Quality
 
Planning JavaScript and Ajax for larger teams
Planning JavaScript and Ajax for larger teamsPlanning JavaScript and Ajax for larger teams
Planning JavaScript and Ajax for larger teams
 
Code quality
Code qualityCode quality
Code quality
 
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard WorkTaming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
 

Recently uploaded

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
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
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
 
#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
 
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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
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
 
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
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 

Recently uploaded (20)

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
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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 ...
 
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
 
#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
 
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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
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
 
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
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
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...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Code Smells

Editor's Notes

  1. Extract Method
  2. An inefficient name is a name that isn't  optimized for the way programmers work. An inefficient names wastes only a second (usually), but it wastes that second over and over again.
  3. Refactor just select method or variable name and Alt+Shift+R
  4. Don’t Repeat Yourself Chain Constructors Extract Composite Extract Method Extract Class Form Template Method Introduce Null Object Introduce Polymorphic Creation with Factory Method Pull Up Method Pull Up Field Replace One/Many Distinctions with Composite Substitute Algorithm Unify Interfaces with Adapter
  5. This smell occurs when you use comments to explain code, rather than making your code self-documenting or intention-revealing. If you write intention-revealing code, your code is so easy to understand that comments become unnecessary. If, on the other hand, your code isn't easy to understand, comments can help explain the code.
  6. Rename Method Extract Method Introduce Assertion
  7. Readable Code. Shorter methods are easier to read and comprehend. Shared Code. Shorter methods provide greater opportunity for fine-grained code sharing. Easier Testing. Shorter methods tend to be easier to microtest (A.K.A. unit test). Extract Method Compose Method Introduce Parameter Object Move Accumulation to Collecting Parameter Move Accumulation to Visitor Decompose Conditional Preserve Whole Object Replace Conditional Dispatcher with Command Replace Conditional Logic with Strategy Replace Method with Method Object Replace Temp with Query
  8. Large classes simply do too much work. They contain too many methods and fields, all of which exist to provide too much diverse functionality for a single class. Many large classes get that way by becoming a convenient dumping ground for newer pieces of functionality that don't have an obvious home. Like large methods, large classes are harder to understand than smaller classes. They don't tend to collaborate with other objects (i.e. little delegation: one object forwarding requests to another object) and their size usually inhibits good hierarchy design. The diverse functionality within large classes tends to attract even more diverse functionality. Large classes perpetuate poor design choices, since it is just so easy to add yet another method to a large class. Extract Class Extract Subclass Extract Interface Replace Data Value with Object Replace Conditional Dispatcher with Command Replace Implicit Language with Interpreter Replace State-Altering Conditionals with State
  9. Extract Class Extract Subclass Extract Interface Replace Data Value with Object Replace Conditional Dispatcher with Command Replace Implicit Language with Interpreter Replace State-Altering Conditionals with State
  10. Such a class may result from moving methods from one class to another. Whatever minor functionality it does provide can be offered by another class, thereby allowing you to delete the lazy class.
  11. Collapse Hierarchy Inline Class Inline Singleton
  12. Collapse Hierarchy Inline Class Inline Singleton
  13. If a minority solution is better than a majority solution,  it ought to become the standard, consistent solution. Unify Interfaces with Adapter
  14. Code that exhibits primitive obsession tends to rely on primitives (like integers or strings) low-level methods classes that don't easily solve problems
  15. Replace Data Value with Object Encapsulate Composite with Builder Introduce Parameter Object Extract Class Move Embellishment to Decorator Replace Conditional Logic with Strategy Replace Implicit Language with Interpreter Replace Implicit Tree with Composite Replace State-Altering Conditionals with State Replace Type Code with Class Replace Type Code with State/Strategy Replace Type Code with Subclasses Replace Array With Object
  16. Move Accumulation to Visitor Replace Conditional Dispatcher with Command Replace Conditional with Polymorphism Replace Type Code with Subclasses Replace Type Code with State/Strategy Replace Parameter with Explicit Methods Introduce Null Object
  17. Collapse Hierarchy Rename Method Remove Parameter Inline Class
  18. Primitive Obsession Replace Parameter with Method Introduce Parameter Object Preserve Whole Object
  19. Introduce Null Object Move Embellishment to Decorator Replace Conditional Logic with Strategy Replace State-Altering Conditionals with State
  20. Introduce Null Object Move Embellishment to Decorator Replace Conditional Logic with Strategy Replace State-Altering Conditionals with State
  21. Replace Specialized Selection with Specification Replace Implicit Language with Interpreter
  22. If similar classes have differences in their interfaces, clients will differ in how they interact with each of the classes. If the classes could share a common interface, clients could work with either class uniformly, thereby removing duplicated client code.
  23. Unify Interfaces with Adapter Rename Method Move Method
  24. Move Method Move Field Change Bidirectional Association to Unidirectional Association Extract Class Hide Delegate Replace Inheritance with Delegation
  25. We don't normally expose wires inside a wall or ceiling. So why do we expose classes that need not be public? Encapsulate Classes with Factory
  26. We don't normally expose wires inside a wall or ceiling. So why do we expose classes that need not be public? Encapsulate Classes with Factory
  27. The Refused Bequest smell occurs when a subclass doesn't support the interface of its superclass. Push Down Field [F 329] Push Down Method [F 322] Replace Inheritance with Delegation [F 352]
  28. The Refused Bequest smell occurs when a subclass doesn't support the interface of its superclass. Push Down Field [F 329] Push Down Method [F 322] Replace Inheritance with Delegation [F 352]
  29. Sometimes a subclass or method doesn't fit in so well with its family.
  30. Sometimes a subclass or method doesn't fit in so well with its family.
  31. This smell often results from quickly adding a feature to a system without spending enough time simplifying and consolidating the design to best accommodate the feature. A typical sign of Solution Sprawl is when code for a feature is spread across three or more classes.
  32. A classic smell is a method that seems more interested in a class other than the one it actually is in.  Extract Method [F 110] Move Method [F 142] Move Field [F 146]
  33. A classic smell is a method that seems more interested in a class other than the one it actually is in.  Extract Method [F 110] Move Method [F 142] Move Field [F 146]
  34. For example, if a method answers a query and also sets the value of a field (for later use by another method), the field may very well be a Temporary Field. Extract Class [F 149] Introduce Null Object [F 260, K 301]
  35. Extract Class Introduce Null Object
  36. Methods ought to perform their primary purpose and avoid doing unrelated or secondary behavior. When a method diverges from its primary purpose, it is probably doing too much work.
  37. Methods ought to perform their primary purpose and avoid doing unrelated or secondary behavior. When a method diverges from its primary purpose, it is probably doing too much work.