Soumettre la recherche
Mettre en ligne
Code Smells
•
1 j'aime
•
573 vues
A
Amandeep Batra
Suivre
Signaler
Partager
Signaler
Partager
1 sur 33
Télécharger maintenant
Télécharger pour lire hors ligne
Recommandé
Developing design sense of code smells
Developing design sense of code smells
Llewellyn Falco
Code smell overview
Code smell overview
Pham Manh Lan
Code Smells and How to avoid it
Code Smells and How to avoid it
Syed Shah
Code smells
Code smells
Leonardo Bernardelli
Code Smells
Code Smells
Mrinal Bhattacaharya
Refactoring-ch7 moving feature btw objects
Refactoring-ch7 moving feature btw objects
fungfung Chen
Agile latvia evening_unit_testing_in_practice
Agile latvia evening_unit_testing_in_practice
denis Udod
Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)
DotNetMarche
Recommandé
Developing design sense of code smells
Developing design sense of code smells
Llewellyn Falco
Code smell overview
Code smell overview
Pham Manh Lan
Code Smells and How to avoid it
Code Smells and How to avoid it
Syed Shah
Code smells
Code smells
Leonardo Bernardelli
Code Smells
Code Smells
Mrinal Bhattacaharya
Refactoring-ch7 moving feature btw objects
Refactoring-ch7 moving feature btw objects
fungfung Chen
Agile latvia evening_unit_testing_in_practice
Agile latvia evening_unit_testing_in_practice
denis Udod
Refactoring 2TheMax (con ReSharper)
Refactoring 2TheMax (con ReSharper)
DotNetMarche
CLEAN WEB
CLEAN WEB
Seda Yalçın
Clean Code - Business Impact
Clean Code - Business Impact
Cathal King
Let's Make the PAIN Visible!
Let's Make the PAIN Visible!
Arty Starr
Reporting Metasystem Design and Penalization Strategy Best Practices (Present...
Reporting Metasystem Design and Penalization Strategy Best Practices (Present...
Intel® Software
Software development
Software development
Olivier Marechal
Code quality as a built-in process
Code quality as a built-in process
Elad Maimon
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
Steven Smith
The Shitposting AI With Thomas Endres & Jonas Mayer | Current 2022
The Shitposting AI With Thomas Endres & Jonas Mayer | Current 2022
HostedbyConfluent
Why #OpenDX?
Why #OpenDX?
Arty Starr
How To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven Peters
ZeroTurnaround
Big guns for small guys (reloaded)
Big guns for small guys (reloaded)
Jorge López-Lago
How to tell a better story (in code)(final)
How to tell a better story (in code)(final)
Bonnie Pan
Rethinking enterprise software - Codemotion 2014
Rethinking enterprise software - Codemotion 2014
Alberto Brandolini
Rethinking Enterprise Software - Brandolini
Rethinking Enterprise Software - Brandolini
Codemotion
Tdd in practice
Tdd in practice
Andrew Meredith
Clean Code Pt I
Clean Code Pt I
Paul Boocock
From keyboard to production
From keyboard to production
Yael Zaritsky Perez
Software as a craft (February, 2018)
Software as a craft (February, 2018)
Rachel M. Carmena
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Joseph Yoder
IT transformation in the world of etsy
IT transformation in the world of etsy
Paul van der Marck
Contenu connexe
Similaire à Code Smells
CLEAN WEB
CLEAN WEB
Seda Yalçın
Clean Code - Business Impact
Clean Code - Business Impact
Cathal King
Let's Make the PAIN Visible!
Let's Make the PAIN Visible!
Arty Starr
Reporting Metasystem Design and Penalization Strategy Best Practices (Present...
Reporting Metasystem Design and Penalization Strategy Best Practices (Present...
Intel® Software
Software development
Software development
Olivier Marechal
Code quality as a built-in process
Code quality as a built-in process
Elad Maimon
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
Steven Smith
The Shitposting AI With Thomas Endres & Jonas Mayer | Current 2022
The Shitposting AI With Thomas Endres & Jonas Mayer | Current 2022
HostedbyConfluent
Why #OpenDX?
Why #OpenDX?
Arty Starr
How To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven Peters
ZeroTurnaround
Big guns for small guys (reloaded)
Big guns for small guys (reloaded)
Jorge López-Lago
How to tell a better story (in code)(final)
How to tell a better story (in code)(final)
Bonnie Pan
Rethinking enterprise software - Codemotion 2014
Rethinking enterprise software - Codemotion 2014
Alberto Brandolini
Rethinking Enterprise Software - Brandolini
Rethinking Enterprise Software - Brandolini
Codemotion
Tdd in practice
Tdd in practice
Andrew Meredith
Clean Code Pt I
Clean Code Pt I
Paul Boocock
From keyboard to production
From keyboard to production
Yael Zaritsky Perez
Software as a craft (February, 2018)
Software as a craft (February, 2018)
Rachel M. Carmena
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Joseph Yoder
IT transformation in the world of etsy
IT transformation in the world of etsy
Paul van der Marck
Similaire à Code Smells
(20)
CLEAN WEB
CLEAN WEB
Clean Code - Business Impact
Clean Code - Business Impact
Let's Make the PAIN Visible!
Let's Make the PAIN Visible!
Reporting Metasystem Design and Penalization Strategy Best Practices (Present...
Reporting Metasystem Design and Penalization Strategy Best Practices (Present...
Software development
Software development
Code quality as a built-in process
Code quality as a built-in process
Cinci ug-january2011-anti-patterns
Cinci ug-january2011-anti-patterns
The Shitposting AI With Thomas Endres & Jonas Mayer | Current 2022
The Shitposting AI With Thomas Endres & Jonas Mayer | Current 2022
Why #OpenDX?
Why #OpenDX?
How To Do Kick-Ass Software Development, by Sven Peters
How To Do Kick-Ass Software Development, by Sven Peters
Big guns for small guys (reloaded)
Big guns for small guys (reloaded)
How to tell a better story (in code)(final)
How to tell a better story (in code)(final)
Rethinking enterprise software - Codemotion 2014
Rethinking enterprise software - Codemotion 2014
Rethinking Enterprise Software - Brandolini
Rethinking Enterprise Software - Brandolini
Tdd in practice
Tdd in practice
Clean Code Pt I
Clean Code Pt I
From keyboard to production
From keyboard to production
Software as a craft (February, 2018)
Software as a craft (February, 2018)
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
Taming Big Balls of Mud with Diligence, Agile Practices, and Hard Work
IT transformation in the world of etsy
IT transformation in the world of etsy
Code Smells
1.
Code Smells: Ooh, Ooh, That Smell ! Amandeep Batra October 2016
2.
Agenda ØWhat are Code Smells? ØWhy do they occur? ØWhat is the Impact? ØCode Smells ØReal World Example Code
3.
Interesting Bay Area Conversations ØWe’d better not touch this code. Last time we did… ØI thought we had a test for this... ØIt always worked, who touched it? ØWhere is e-mail about this issue? ØAssigning this to X who will come back on next Thursday ØJust add a TODO comment ØLets put a Hack for now ØLets create a SIM for Refactoring for now ØLets Deliver Results for now
4.
What are Code Smells? ØCode Smells are anti-pattern which represents hazards in the code ØIt is a design that duplicates, complicates or tightly couples code ØAnother similar term we commonly use is called Technical Debt ØRecognizing hazards in the code is the first step in improving code
5.
Why do they occur? ØConsciously: when we defer ØUnconsciously: when we don’t even
6.
What is the impact?
7.
Lost Intent
8.
Lost Intent Example
9.
Inefficient Naming
10.
Inefficient Naming In a Game, we need to write a function on direction the soldier is facing getDrctn() : Shorteing a vowel is bad getDir() : Misleading getDirection() : Right
11.
Duplicated Code • DRY: Don’t Repeat Yourself
12.
Duplicated Code • DRY: Don’t Repeat Yourself
13.
Deodorant Comment ØIf you write intention revealing code then comments are unnecessary
14.
Long Method ØLike a very large burger, too hard to digest Shorter composed methods are - More Readable - Provide greater opportunity for code sharing, less duplication -
Easier to test
15.
Large Class ØLike people, classes suffer when they take too many responsibilities
16.
ØAll of us would dispose of a pet goldfish if it met an unhappy end. Yet how many of us dispose of code that is no longer being used? ØLeads to • Increased Complexity • Accidental Changes •
More Dead Code Dead Code
17.
Oddball Solution ØWhen a problem is solved one way throughout a system and same is solved another way in same system
18.
Oddball Solution
19.
Primitive Obsession ØCode that exhibits primitive obsession tends to rely on: • primitives (like integers or strings) • low-level methods •
classes that don't easily solve problems ØCode that suffers from this smell fails to leverage higher level abstractions. if (someString.indexOf("substring") != -1) Instead of if (someString.contains("substring"))
20.
Speculative Generality Ø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
21.
Combinatorial Explosion ØWhen new combinations of data or behavior further bloat an already bloated design
22.
Combinatorial Explosion ØList readOnlySortedList = new ReadOnlyList( new SortedList( new ArrayList(...) ) );
23.
Black Sheep ØA black sheep is a family member that doesn't fit in so well, it could be a sub-class or a method in a class
24.
Black Sheep
25.
Feature Envy ØResponsibilities of performing a job is in wrong place
26.
Feature Envy
27.
Refused Bequest ØSubclasses gets to inherit the methods and data of their parents. But what if they don't want or need what they are given? public abstract class
AbstractCollection… public abstract void add(Object element); public class Map extends AbstractCollection… // Do nothing because user must input key and value public void add(Object element) { }
28.
Other Smells ØLong Parameterized List : The more the parameters, difficult is to read, prefer an Object ØIndecent Exposure : Beware of classes that unnecessarily expose their internals. Aggressively refactor classes to minimize their public surface.
29.
Example Code ØLet’s find out some code smells here
30.
Some Tips Ø“Always code as if person who will maintain your code is a maniac serial killer who knows where you live” Ø “Always leave the code in better state than it is today”
31.
Resources ØRefactoring to Patterns Book ØCoding Horror Blog
32.
Q&A
33.
Thanks !
Télécharger maintenant