SlideShare a Scribd company logo
1 of 19
Your Code Smells Too!
Time to Deodorize
Gino Marckx
cb pyroclastichawk - https://www.flickr.com/photos/18536761@N00/367669179
cb Iwan Gabovitch - https://www.flickr.com/photos/qubodup/4439090296
cb Iwan Gabovitch - https://www.flickr.com/photos/qubodup/4438310359
CAUTION
BAD ROAD
AHEAD
CAUTION
BAD CODE
AHEAD
public class Person {
public String m_name;
public String m_street;
public String m_zip;
public String m_city;
public String m_province;
public String m_country;
public Person(String name, String country) { ... }
public Person(String name, String town, String country) { ... }
public Person(String name, String s, String z, String c, String p,
String country) { ... } 

public void add(Person person) { ... }
public final List getFriends() { ... }
public double between(Person person) { ... }
public Person closestFriend() { ... }
}
The Wallaroo Prints © 2011
public class Person {
public String name;
public Address address;
public Person(String name, Address address) { ... }
public void addFriend(Person person) { ... }
public List<Person> getFriends() { ... }
/**
* Find the friend who lives closest.
*
* @return the friend who lives closest
* @throws NoSuchElementException in case this person has no friends
*/
public Person getNearestFriend() { ... }
}
• Meaningful names
• Excessive use of literals
• Long parameter list
• Excessively short identifiers
• Feature envy
• Readability
• Maintainability
• Velocity
public class Address {
public Address(String country) { ... }
public Address(String city, String country) { ... }
public Address(String street, String postalCode, String city,
String state, String country) { ... }
public String getStreet() { ... }
public String getPostalCode() { ... }
public String getCity() { ... }
public String getState() { ... }
public String getCountry() { ... }
public Point getGeographicalLocation() { ... }
/**
* Calculate the distance in kilometres to another address.
*
* @param anotherAddress the other address to calculate the distance to
* @return the distance in kilometres between this address and the other
* address
* @throws IllegalArgumentException when location of either address is
* unknown
*/
public double distanceTo(Address anotherAddress) { ... }
}
http://www.zazzle.ca/comments_a_deodorant_to_mask_code_smells_tshirt-235182622652051339
The Wallaroo Prints © 2011
public class AddressBuilder {
public AddressBuilder(AddressLocator addressLocator) { ... }
public AddressBuilder() { ... }
public AddressBuilder withCountry(String country) { ... }
public AddressBuilder withStreet(String street) { ... }
public AddressBuilder withCity(String city) { ... }
public AddressBuilder withPostalCode(String postalCode) { ... }
public AddressBuilder withState(String state) { ... }
public Address build() throws UnknownGeographicalLocation { ... }
}
public class Address {
Address(AddressLocator locator, String street, String zipCode,
String city, String state, String country) { ... }
...
public Distance distanceTo(Address anotherAddress) { ... }
}
public class AddressTest {
public AddressLocator createMockLocatorWithPolandCentreOfTheUniverse() {
... }
@Test
public void testDistanceTo() throws Throwable {
AddressBuilder builder = new AddressBuilder(
createMockLocatorWithPolandCentreOfTheUniverse());
Address polishAddress = builder.withCountry("Poland").build(),
canadianAddress = builder.withCountry("Canada").build();
assertEquals(new Distance(1000, Distance.Unit.KILOMETRE),
polishAddress.distanceTo(canadianAddress));
}
}
• Dependency inversion
• Excessive use of literals
• Long parameter list
• Feature envy
• Testability
• Maintainability
• Velocity
Velocity
Testability
Maintainability
Build Software

The Right Way
… to be agile
Thank you!
Gino Marckx
Director, Agile Competency Center

More Related Content

More from Gino Marckx

Measuring outcomes... or how to get meaningful metrics
Measuring outcomes... or how to get meaningful metricsMeasuring outcomes... or how to get meaningful metrics
Measuring outcomes... or how to get meaningful metricsGino Marckx
 
Building powerful roadmaps
Building powerful roadmapsBuilding powerful roadmaps
Building powerful roadmapsGino Marckx
 
Increase your coaching capacity
Increase your coaching capacityIncrease your coaching capacity
Increase your coaching capacityGino Marckx
 
Don't go Agile unless you know why
Don't go Agile unless you know whyDon't go Agile unless you know why
Don't go Agile unless you know whyGino Marckx
 
Why agile doesn't work in your organization
Why agile doesn't work in your organizationWhy agile doesn't work in your organization
Why agile doesn't work in your organizationGino Marckx
 
Quadrants of Effectiveness v2.0
Quadrants of Effectiveness v2.0Quadrants of Effectiveness v2.0
Quadrants of Effectiveness v2.0Gino Marckx
 

More from Gino Marckx (8)

Measuring outcomes... or how to get meaningful metrics
Measuring outcomes... or how to get meaningful metricsMeasuring outcomes... or how to get meaningful metrics
Measuring outcomes... or how to get meaningful metrics
 
Building powerful roadmaps
Building powerful roadmapsBuilding powerful roadmaps
Building powerful roadmaps
 
Increase your coaching capacity
Increase your coaching capacityIncrease your coaching capacity
Increase your coaching capacity
 
Don't go Agile unless you know why
Don't go Agile unless you know whyDon't go Agile unless you know why
Don't go Agile unless you know why
 
Why agile doesn't work in your organization
Why agile doesn't work in your organizationWhy agile doesn't work in your organization
Why agile doesn't work in your organization
 
Quadrants of Effectiveness v2.0
Quadrants of Effectiveness v2.0Quadrants of Effectiveness v2.0
Quadrants of Effectiveness v2.0
 
Both Sides
Both SidesBoth Sides
Both Sides
 
Pomodoro Show
Pomodoro ShowPomodoro Show
Pomodoro Show
 

Recently uploaded

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 

Recently uploaded (20)

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 

Your code smells too! Time to deodorize

  • 1. Your Code Smells Too! Time to Deodorize Gino Marckx
  • 2. cb pyroclastichawk - https://www.flickr.com/photos/18536761@N00/367669179
  • 3. cb Iwan Gabovitch - https://www.flickr.com/photos/qubodup/4439090296
  • 4. cb Iwan Gabovitch - https://www.flickr.com/photos/qubodup/4438310359
  • 7. public class Person { public String m_name; public String m_street; public String m_zip; public String m_city; public String m_province; public String m_country; public Person(String name, String country) { ... } public Person(String name, String town, String country) { ... } public Person(String name, String s, String z, String c, String p, String country) { ... } 
 public void add(Person person) { ... } public final List getFriends() { ... } public double between(Person person) { ... } public Person closestFriend() { ... } }
  • 9. public class Person { public String name; public Address address; public Person(String name, Address address) { ... } public void addFriend(Person person) { ... } public List<Person> getFriends() { ... } /** * Find the friend who lives closest. * * @return the friend who lives closest * @throws NoSuchElementException in case this person has no friends */ public Person getNearestFriend() { ... } }
  • 10. • Meaningful names • Excessive use of literals • Long parameter list • Excessively short identifiers • Feature envy • Readability • Maintainability • Velocity
  • 11. public class Address { public Address(String country) { ... } public Address(String city, String country) { ... } public Address(String street, String postalCode, String city, String state, String country) { ... } public String getStreet() { ... } public String getPostalCode() { ... } public String getCity() { ... } public String getState() { ... } public String getCountry() { ... } public Point getGeographicalLocation() { ... } /** * Calculate the distance in kilometres to another address. * * @param anotherAddress the other address to calculate the distance to * @return the distance in kilometres between this address and the other * address * @throws IllegalArgumentException when location of either address is * unknown */ public double distanceTo(Address anotherAddress) { ... } }
  • 14. public class AddressBuilder { public AddressBuilder(AddressLocator addressLocator) { ... } public AddressBuilder() { ... } public AddressBuilder withCountry(String country) { ... } public AddressBuilder withStreet(String street) { ... } public AddressBuilder withCity(String city) { ... } public AddressBuilder withPostalCode(String postalCode) { ... } public AddressBuilder withState(String state) { ... } public Address build() throws UnknownGeographicalLocation { ... } } public class Address { Address(AddressLocator locator, String street, String zipCode, String city, String state, String country) { ... } ... public Distance distanceTo(Address anotherAddress) { ... } }
  • 15. public class AddressTest { public AddressLocator createMockLocatorWithPolandCentreOfTheUniverse() { ... } @Test public void testDistanceTo() throws Throwable { AddressBuilder builder = new AddressBuilder( createMockLocatorWithPolandCentreOfTheUniverse()); Address polishAddress = builder.withCountry("Poland").build(), canadianAddress = builder.withCountry("Canada").build(); assertEquals(new Distance(1000, Distance.Unit.KILOMETRE), polishAddress.distanceTo(canadianAddress)); } }
  • 16. • Dependency inversion • Excessive use of literals • Long parameter list • Feature envy • Testability • Maintainability • Velocity
  • 18. Build Software
 The Right Way … to be agile
  • 19. Thank you! Gino Marckx Director, Agile Competency Center