SlideShare a Scribd company logo
1 of 46
Anti-patterns part 2

Dmitriy Kochergin, Developer
Dnepropetrovsk, 2012


August 7, 2012   www.ExigenServices.com
Content


• Programming anti-patterns
• Methodological anti-patterns
• Configuration management anti-patterns




     2                                     2   www.ExigenServices.com
Part 1
    Programming anti-patterns




3                               3   www.ExigenServices.com
Accidental complexity

• Accidental complexity: Introducing unnecessary complexity
  into a solution
• While essential complexity is inherent and unavoidable,
  accidental complexity is caused by the approach chosen to
  solve the problem
   – essential complexity: we have a hard problem
   – accidental complexity: we have made a problem hard
   – KISS principle




      4                                               4   www.ExigenServices.com
Accidental complexity

• Solution:
   – Focus on the essential complexity
   – Avoid “tricky code”
   – After implementation check if your solution follow business problem




      5                                                 5     www.ExigenServices.com
Accidental complexity




6                   6   www.ExigenServices.com
Blind faith

• Blind faith (or blind programming): programmer develops a
  solution or fixes a computer bug and deploys it without
  testing
• The programmer has blind faith in his abilities
• Another form of blind faith is when a programmer calls a
  subroutine without checking the result (e.g. for null)




       7                                        7    www.ExigenServices.com
Boat anchor

• Boat anchor refers to an unused piece of code that is left in
  code, typically for the reason "In case we need it later”
• Problem:
   – hard to differentiate between obsolete code and working code
   – later it usually easier to rewrite method
   – uncommenting code can cause bugs
• Use VCS to get old version if needed




        8                                               8     www.ExigenServices.com
Cargo cult programming

• Cargo cult originally referred to aboriginal religions which
  grew up in the South Pacific after World War II
• Cargo cult programming: Using patterns, technologies,
  frameworks without understanding why




       9                                            9    www.ExigenServices.com
Cargo cult programming




10                   10   www.ExigenServices.com
Coding by exception

• Coding by exception: Adding new code to handle each special
  case when it appears
• Typically happens due to covering new requirements
• 'One-off' solutions decrease performance and maintainability


• Try to generalize the special case first
• Well designed software projects contain
  very few corner cases



         11                                       11    www.ExigenServices.com
Error hiding


• Error hiding: catching an error message before it can be shown
  to the user and either showing nothing or showing a
  meaningless message
• Cause: desire to hide complexity from the user
• Solution: Raise an exception to the user with simplified error
  message, and save the full error message to an error log
• User should understand what to do from error message,
  provide possible solutions



         12                                        12    www.ExigenServices.com
Hard coding

• Hard coding: storing configuration data in source code rather
  than configuration files
   –   configuration file path
   –   mail server name
   –   remote hosts
   –   … other system environment variables
• Program could work correctly only in certain environment (on
  developer machine)
• Every new environment (including build servers) should be tuned
  to comply with hardcoded (predefined) structure

           13                                      13    www.ExigenServices.com
Hard coding


• Solution:
   –   obtain data from external sources
   –   generate data
   –   take it from user input
   –   pass data through command line or system property




           14                                              14   www.ExigenServices.com
Soft coding


• Soft coding: storing business logic in external resources rather
  than in source code
• Example: storing business rules in DB
• Reason: fear that the code we write will have to be changed as a
  result of a business rule change
• Solution: avoid Hard Coding and Soft Coding




         15                                        15    www.ExigenServices.com
Magic numbers


• Magic numbers: Including unexplained numbers in algorithms

• Replace them with constants:
   • it is easier to read and understand
   • it is easier to alter the value of the number, as it is
     not duplicated
   • it helps detect typos




          16                                                   16   www.ExigenServices.com
Spaghetti code

• Spaghetti code: code that has a complex and tangled control
  structure, especially one using many GOTOs, exceptions, threads,
  or other "unstructured" branching constructs

• Now term is used to describe any
  code with tangled and twisted
  logic, lots of
  branching, polymorphic behavior
  etc




         17                                        17    www.ExigenServices.com
Spaghetti code




Un-structured code    Well-structured code
   is a liability      is an investment

   18                            18   www.ExigenServices.com
Spaghetti code

• Structured programming greatly decreased the
  incidence of spaghetti code: extensive use of
  subroutines, block structures and for and while loops

• Functions not more than 10-20 rows
• Use metrics to find spaghetti methods, e.g.
  cyclomatic complexity, method length.




         19                                     19   www.ExigenServices.com
Spaghetti code: Other related
                          terms

• Ravioli code: program structure is characterized by a number of
  small and (ideally) loosely-coupled components
• While generally desirable from a coupling and cohesion
  perspective, overzealous separation and encapsulation of code
  can bloat call stacks and make navigation through the code more
  difficult




         20                                       20    www.ExigenServices.com
Shotgun surgery


• Shotgun surgery: features are added to several
  places simultaneously, usually by copy-pasting
  with slight variations
• Solution: Aspect oriented programming (AOP)




        21                                         21   www.ExigenServices.com
Shot in the Dark


• Shot in the Dark: production (or test) environment poor track
  record leads to developers are guessing possible problems
• “We can’t reproduce the problem in QA but I think it is caused
  by feature “X””
• Solution: Measure, Don’t Guess
   – local bug reproducing
   – error stack trace
   – profiler




        22                                         22    www.ExigenServices.com
Incorrect exceptions usage

• Incorrect exceptions usage: normal program flow
  implemented using exceptions
   – exit from block using exception
   – similar to goto statement
• Using exceptions to control program flow adds ambiguity
• Solution: use exception only to inform program about
  errors. Checked – for recoverable errors, unchecked – for
  unrecoverable errors




        23                                        23    www.ExigenServices.com
Incorrect data

• Incorrect data: could cause errors anytime during program
  execution
• In contrast to program flow errors data errors are hardly
  exposed because data could be corrupted any stage earlier
• Solution:
   – check data as early as possible
   – check input data of methods (design by contract and firewalls)




        24                                                24     www.ExigenServices.com
Lava flow

• Lava flow: Retaining undesirable (redundant or low-quality)
  code because removing it is too expensive or has
  unpredictable consequences

• If you leave tricky code –
  describe your solution in
  javadoc or comments
• Write tests – then you will
  be confident in refactoring



      25                                        25    www.ExigenServices.com
Lava flow




26               26   www.ExigenServices.com
Other programming anti-
                         patterns

• Busy waiting: consuming CPU while waiting for something
  to happen, usually by repeated checking instead of
  messaging
• Negative cache is a cache that also stores "negative"
  responses (result indicating error).
   – e.g. when network was unavailable – cache error result, and
     return it even after network is back up.




      27                                               27     www.ExigenServices.com
Part 2
     Methodological anti-patterns




28                              28   www.ExigenServices.com
Copy and paste programming

• Copy-paste programming: describe highly repetitive code
  apparently produced by copy and paste operations

• Use extract method refactoring




        29                                      29    www.ExigenServices.com
Copy and paste programming

• Follow Don't Repeat Yourself (DRY) principle
   • modification of any element does not require a changes in
      other logically-unrelated elements




        30                                         30    www.ExigenServices.com
Golden hammer

• Golden hammer (Maslow's hammer, law of the
  instrument): assuming that a favorite solution is universally
  applicable
• “If all you have is a hammer, everything looks like a nail"
                                             Abraham Maslow, 1966




       31                                          31     www.ExigenServices.com
Golden hammer

• Solution:
   – look at the problem from different points of view
   – choose technology (concept, framework or tool) that better suits
     to solve the problem
   – previous means you have o know at least on more solution to
     problem (learn it if needed)
   – There are 191 fundamental software patterns (23 Gamma
     Patterns + 17 Buschmann Patterns + 72 Analysis Patterns + 38
     CORBA Design Patterns + 42 AntiPatterns)
   – [4] describes 140 antipatterns




       32                                               32     www.ExigenServices.com
Improbability factor

• Improbability factor: assuming that known error is improbable
  to occur
   – programmers are aware of the problem
   – they are not allowed to fix the problem
   – because the chances of the problem ever appearing are supposedly
     negligible compared to other problems that could be solved with the
     programmers' time and money




        33                                              33     www.ExigenServices.com
Improbability factor

• As a result, the problem may still occur and do heavy damage due
  to Murphy's law
• Murphy's law typically stated as:
"Anything that can go wrong, will go wrong”




      34                                        34    www.ExigenServices.com
Premature optimization


• Premature optimization: Coding early-on for perceived efficiency,
  sacrificing good design, maintainability, and sometimes even real-world
  efficiency
• "We should forget about small efficiencies, say about 97% of the time:
  premature optimization is the root of all evil"
                                                               Donald Knuth, 1974
• A simple and elegant design is often easier to optimize
• In practice, it is often necessary to keep performance goals in mind when
  first designing software, but the programmer balances the goals of design
  and optimization



         35                                               35       www.ExigenServices.com
Premature pessimization


• Premature pessimization: Coding early-on for good design, leaving
  performance intentionally low
    – multiple copying heavyweight container
    – recalculating rather than caching
    – etc
• Solution should be optimal (not optimized) for task




         36                                              36     www.ExigenServices.com
Programming by permutation

• Programming by permutation (or "programming by accident"):
  trying to find a solution by making small changes (permutations)
  to see if it works
• Programmer trying to guess:
   – calls and order of procedures
   – parameters' values
   – etc.
• Reason:
   – programmer does not fully understand the code or even don’t want to
     understand it
   – external module API is insufficiently documented

        37                                             37     www.ExigenServices.com
Programming by permutation


• Problems:
   – new bugs can be introduced, leading to a "solution" that is even less
     correct than the starting point
   – it’s usually impossible to tell whether the solution will work for all cases
   – programming by permutation gives little or no assurance about the
     quality of the code produced




        38                                                   38      www.ExigenServices.com
Reinventing the square wheel


• Reinventing the square wheel: Failing to adopt an existing,
  adequate solution and instead creating a custom solution
  (reinventing the wheel) which performs much worse than the
  existing one (a square wheel).
• Reason:
   – engineer doesn’t know the standard solution
   – engineer doesn’t like the standard solution
   – second-system effect




        39                                         39   www.ExigenServices.com
Reinventing the square wheel


• Problems:
   – anyone starting from scratch, ignoring
     the prior art, will naturally face same
     old problems again
   – wasted development time, delaying a
     task
   – developers will have to support their
     solution, fixing bugs and adding new
     features




        40                                     40   www.ExigenServices.com
Part 3
Configuration management anti-patterns




  41                           41   www.ExigenServices.com
Dependency hell

• Dependency hell (DLL hell, JAR hell): problems with versions of
  required products
• Problems:
   – many dependencies
       • high coupling
   – long chains of dependencies
   – conflicting dependencies
       • if different versions of lib
       cannot be simultaneously
       installed
   – circular dependencies
       • you can’t separate units
       by level of abstraction
         42                                       42    www.ExigenServices.com
Dependency hell


• Solutions:
   – version numbering (major and minor versions)
   – smart package management (e.g. in Linux)
       • repository-based package management systems
   – software appliances (encapsulate dependencies in a one unit)
   – portable applications




        43                                              43     www.ExigenServices.com
THANKS FOR COMING!!!

• My contacts:
   – e-mail: dmitriy.kochergin@exigenservices.com
   – Skype: dmitry.kochergin




          44                                        44   www.ExigenServices.com
Questions




     Questions?




45                   45   www.ExigenServices.com
Links

Nr.   Document                                 Author, Date, Location
[1]   Anti-patterns wiki                       •http://en.wikipedia.org/wiki/Anti-patterns
[2]   AnemicDomainModel                        •http://www.martinfowler.com/bliki/AnemicDomainModel.html
[3]   AntiPatterns                             •http://www.antipatterns.com/briefing/sld001.htm
[4]   AntiPatterns catalog                     •http://c2.com/cgi-bin/wiki?AntiPatternsCatalog
[5]   Supported by the Antipattern template    •http://c2.com/cgi-bin/wiki?AntiPatternTemplate
[6]   AntiPatterns: Refactoring Software,
      Architectures, and
      Projects in Crisis by William J. Brown
      et.al. (Wiley)
[7]   AntiPatterns                             •http://sourcemaking.com/antipatterns




                     46                                                                           46       www.ExigenServices.com

More Related Content

What's hot

Building a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersBuilding a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersAmazon Web Services
 
CI and CD with Jenkins
CI and CD with JenkinsCI and CD with Jenkins
CI and CD with JenkinsMartin Málek
 
Treating Your Pipeline as a Product - Full Day Workshop
Treating Your Pipeline as a Product - Full Day WorkshopTreating Your Pipeline as a Product - Full Day Workshop
Treating Your Pipeline as a Product - Full Day WorkshopManuel Pais
 
Inception: From vision to product
Inception: From vision to product Inception: From vision to product
Inception: From vision to product Nico Spadoni
 
Keynote: Frozen DevOps? The not-so-technical Last Mile @ DevOpsDays Portugal,...
Keynote: Frozen DevOps? The not-so-technical Last Mile @ DevOpsDays Portugal,...Keynote: Frozen DevOps? The not-so-technical Last Mile @ DevOpsDays Portugal,...
Keynote: Frozen DevOps? The not-so-technical Last Mile @ DevOpsDays Portugal,...Manuel Pais
 
Continuous Lifecycle London 2018 Event Keynote
Continuous Lifecycle London 2018 Event KeynoteContinuous Lifecycle London 2018 Event Keynote
Continuous Lifecycle London 2018 Event KeynoteWeaveworks
 
Advanced GitHub Enterprise Administration
Advanced GitHub Enterprise AdministrationAdvanced GitHub Enterprise Administration
Advanced GitHub Enterprise AdministrationLars Schneider
 
The Need of Cloud-Native Application
The Need of Cloud-Native ApplicationThe Need of Cloud-Native Application
The Need of Cloud-Native ApplicationEmiliano Pecis
 
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...GITS Indonesia
 
Understanding Branching and Merging in Git
Understanding Branching and Merging in GitUnderstanding Branching and Merging in Git
Understanding Branching and Merging in Gitgittower
 
Dealing with Merge Conflicts in Git
Dealing with Merge Conflicts in GitDealing with Merge Conflicts in Git
Dealing with Merge Conflicts in Gitgittower
 
Fundamentals of DevOps and CI/CD
Fundamentals of DevOps and CI/CDFundamentals of DevOps and CI/CD
Fundamentals of DevOps and CI/CDBatyr Nuryyev
 
Spiking Your Way to Improved Agile Development - Anatoli Kazatchkov
Spiking Your Way to Improved Agile Development - Anatoli KazatchkovSpiking Your Way to Improved Agile Development - Anatoli Kazatchkov
Spiking Your Way to Improved Agile Development - Anatoli KazatchkovAtlassian
 
Troubleshooting redis
Troubleshooting redisTroubleshooting redis
Troubleshooting redisDaeMyung Kang
 
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...Edureka!
 
Workshop : Innovation Games at NSSpain
Workshop : Innovation Games at NSSpainWorkshop : Innovation Games at NSSpain
Workshop : Innovation Games at NSSpainBen Sykes
 

What's hot (20)

Building a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersBuilding a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containers
 
CI and CD with Jenkins
CI and CD with JenkinsCI and CD with Jenkins
CI and CD with Jenkins
 
Jenkins Overview
Jenkins OverviewJenkins Overview
Jenkins Overview
 
Treating Your Pipeline as a Product - Full Day Workshop
Treating Your Pipeline as a Product - Full Day WorkshopTreating Your Pipeline as a Product - Full Day Workshop
Treating Your Pipeline as a Product - Full Day Workshop
 
Anti-Patterns
Anti-PatternsAnti-Patterns
Anti-Patterns
 
Inception: From vision to product
Inception: From vision to product Inception: From vision to product
Inception: From vision to product
 
Anti Patterns
Anti PatternsAnti Patterns
Anti Patterns
 
Keynote: Frozen DevOps? The not-so-technical Last Mile @ DevOpsDays Portugal,...
Keynote: Frozen DevOps? The not-so-technical Last Mile @ DevOpsDays Portugal,...Keynote: Frozen DevOps? The not-so-technical Last Mile @ DevOpsDays Portugal,...
Keynote: Frozen DevOps? The not-so-technical Last Mile @ DevOpsDays Portugal,...
 
Continuous Lifecycle London 2018 Event Keynote
Continuous Lifecycle London 2018 Event KeynoteContinuous Lifecycle London 2018 Event Keynote
Continuous Lifecycle London 2018 Event Keynote
 
Advanced GitHub Enterprise Administration
Advanced GitHub Enterprise AdministrationAdvanced GitHub Enterprise Administration
Advanced GitHub Enterprise Administration
 
The Need of Cloud-Native Application
The Need of Cloud-Native ApplicationThe Need of Cloud-Native Application
The Need of Cloud-Native Application
 
Gitlab CI/CD
Gitlab CI/CDGitlab CI/CD
Gitlab CI/CD
 
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
GITS Class #16: CI/CD (Continuous Integration & Continuous Deployment) with G...
 
Understanding Branching and Merging in Git
Understanding Branching and Merging in GitUnderstanding Branching and Merging in Git
Understanding Branching and Merging in Git
 
Dealing with Merge Conflicts in Git
Dealing with Merge Conflicts in GitDealing with Merge Conflicts in Git
Dealing with Merge Conflicts in Git
 
Fundamentals of DevOps and CI/CD
Fundamentals of DevOps and CI/CDFundamentals of DevOps and CI/CD
Fundamentals of DevOps and CI/CD
 
Spiking Your Way to Improved Agile Development - Anatoli Kazatchkov
Spiking Your Way to Improved Agile Development - Anatoli KazatchkovSpiking Your Way to Improved Agile Development - Anatoli Kazatchkov
Spiking Your Way to Improved Agile Development - Anatoli Kazatchkov
 
Troubleshooting redis
Troubleshooting redisTroubleshooting redis
Troubleshooting redis
 
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
 
Workshop : Innovation Games at NSSpain
Workshop : Innovation Games at NSSpainWorkshop : Innovation Games at NSSpain
Workshop : Innovation Games at NSSpain
 

Viewers also liked

Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012
Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012
Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012TEST Huddle
 
Java Pitfalls and Good-to-Knows
Java Pitfalls and Good-to-KnowsJava Pitfalls and Good-to-Knows
Java Pitfalls and Good-to-KnowsMiquel Martin
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javapriyankazope
 
Coding best practices_exception handling
Coding best practices_exception handlingCoding best practices_exception handling
Coding best practices_exception handlingAbid Khan
 
OCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 ExceptionsOCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 Exceptionsİbrahim Kürce
 
Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in javaVidya Bharti
 
Exception handling and logging best practices
Exception handling and logging best practicesException handling and logging best practices
Exception handling and logging best practicesAngelin R
 

Viewers also liked (10)

Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012
Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012
Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012
 
Java Pitfalls and Good-to-Knows
Java Pitfalls and Good-to-KnowsJava Pitfalls and Good-to-Knows
Java Pitfalls and Good-to-Knows
 
Anti patterns part 1
Anti patterns part 1Anti patterns part 1
Anti patterns part 1
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Coding best practices_exception handling
Coding best practices_exception handlingCoding best practices_exception handling
Coding best practices_exception handling
 
null Bachaav Session | Secure Coding in Java
null Bachaav Session | Secure Coding in Javanull Bachaav Session | Secure Coding in Java
null Bachaav Session | Secure Coding in Java
 
OCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 ExceptionsOCA Java SE 8 Exam Chapter 6 Exceptions
OCA Java SE 8 Exam Chapter 6 Exceptions
 
Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
 
Exception handling and logging best practices
Exception handling and logging best practicesException handling and logging best practices
Exception handling and logging best practices
 
Java & J2EE Coding Conventions
Java & J2EE Coding ConventionsJava & J2EE Coding Conventions
Java & J2EE Coding Conventions
 

Similar to Anti patterns part 2

10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware ProgrammingPostSharp Technologies
 
Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)lqi
 
How to really obfuscate your pdf malware
How to really obfuscate   your pdf malwareHow to really obfuscate   your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Talent42 2014 Sam Wholley -
Talent42 2014 Sam Wholley - Talent42 2014 Sam Wholley -
Talent42 2014 Sam Wholley - Talent42
 
Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014Lari Hotari
 
Architectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyArchitectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyComsysto Reply GmbH
 
Architectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyArchitectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyComsysto Reply GmbH
 
Get your Project back in Shape!
Get your Project back in Shape!Get your Project back in Shape!
Get your Project back in Shape!Joachim Tuchel
 
Использование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложенийИспользование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложенийVitebsk Miniq
 
Surviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studySurviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studypeter_ibuildings
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality codeHayden Bleasel
 
Tool Up Your LAMP Stack
Tool Up Your LAMP StackTool Up Your LAMP Stack
Tool Up Your LAMP StackLorna Mitchell
 
Growing as a software craftsperson (part 1) From Pune Software Craftsmanship.
Growing as a software craftsperson (part 1)  From Pune Software Craftsmanship.Growing as a software craftsperson (part 1)  From Pune Software Craftsmanship.
Growing as a software craftsperson (part 1) From Pune Software Craftsmanship.Dattatray Kale
 
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013Christopher Curtin
 
Started In Security Now I'm Here
Started In Security Now I'm HereStarted In Security Now I'm Here
Started In Security Now I'm HereChristopher Grayson
 

Similar to Anti patterns part 2 (20)

Anti patterns part 2
Anti patterns part 2Anti patterns part 2
Anti patterns part 2
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)Slides for Houston iPhone Developers' Meetup (April 2012)
Slides for Houston iPhone Developers' Meetup (April 2012)
 
How to really obfuscate your pdf malware
How to really obfuscate   your pdf malwareHow to really obfuscate   your pdf malware
How to really obfuscate your pdf malware
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Talent42 2014 Sam Wholley -
Talent42 2014 Sam Wholley - Talent42 2014 Sam Wholley -
Talent42 2014 Sam Wholley -
 
Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014Performance tuning Grails applications SpringOne 2GX 2014
Performance tuning Grails applications SpringOne 2GX 2014
 
Architectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyArchitectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and Consistently
 
Architectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyArchitectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and Consistently
 
Get your Project back in Shape!
Get your Project back in Shape!Get your Project back in Shape!
Get your Project back in Shape!
 
Simics - Break the Rules of Product Development
Simics - Break the Rules of Product DevelopmentSimics - Break the Rules of Product Development
Simics - Break the Rules of Product Development
 
Использование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложенийИспользование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложений
 
Surviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studySurviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-study
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
 
Tool up your lamp stack
Tool up your lamp stackTool up your lamp stack
Tool up your lamp stack
 
Tool Up Your LAMP Stack
Tool Up Your LAMP StackTool Up Your LAMP Stack
Tool Up Your LAMP Stack
 
Growing as a software craftsperson (part 1) From Pune Software Craftsmanship.
Growing as a software craftsperson (part 1)  From Pune Software Craftsmanship.Growing as a software craftsperson (part 1)  From Pune Software Craftsmanship.
Growing as a software craftsperson (part 1) From Pune Software Craftsmanship.
 
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
 
Started In Security Now I'm Here
Started In Security Now I'm HereStarted In Security Now I'm Here
Started In Security Now I'm Here
 

More from Return on Intelligence

Profsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by PavelchukProfsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by PavelchukReturn on Intelligence
 
Types of testing and their classification
Types of testing and their classificationTypes of testing and their classification
Types of testing and their classificationReturn on Intelligence
 
Service design principles and patterns
Service design principles and patternsService design principles and patterns
Service design principles and patternsReturn on Intelligence
 
Differences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and AgileDifferences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and AgileReturn on Intelligence
 
Организация внутренней системы обучения
Организация внутренней системы обученияОрганизация внутренней системы обучения
Организация внутренней системы обученияReturn on Intelligence
 
Shared position in a project: testing and analysis
Shared position in a project: testing and analysisShared position in a project: testing and analysis
Shared position in a project: testing and analysisReturn on Intelligence
 
Оценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработкеОценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработкеReturn on Intelligence
 
Successful interview for a young IT specialist
Successful interview for a young IT specialistSuccessful interview for a young IT specialist
Successful interview for a young IT specialistReturn on Intelligence
 

More from Return on Intelligence (20)

Profsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by PavelchukProfsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by Pavelchuk
 
Agile Project Grows
Agile Project GrowsAgile Project Grows
Agile Project Grows
 
Types of testing and their classification
Types of testing and their classificationTypes of testing and their classification
Types of testing and their classification
 
Time Management
Time ManagementTime Management
Time Management
 
Service design principles and patterns
Service design principles and patternsService design principles and patterns
Service design principles and patterns
 
Differences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and AgileDifferences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and Agile
 
Windows Azure: Quick start
Windows Azure: Quick startWindows Azure: Quick start
Windows Azure: Quick start
 
Windows azurequickstart
Windows azurequickstartWindows azurequickstart
Windows azurequickstart
 
Организация внутренней системы обучения
Организация внутренней системы обученияОрганизация внутренней системы обучения
Организация внутренней системы обучения
 
Shared position in a project: testing and analysis
Shared position in a project: testing and analysisShared position in a project: testing and analysis
Shared position in a project: testing and analysis
 
Introduction to Business Etiquette
Introduction to Business EtiquetteIntroduction to Business Etiquette
Introduction to Business Etiquette
 
Agile Testing Process
Agile Testing ProcessAgile Testing Process
Agile Testing Process
 
Оценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработкеОценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработке
 
Meetings arranging
Meetings arrangingMeetings arranging
Meetings arranging
 
How to develop your creativity
How to develop your creativityHow to develop your creativity
How to develop your creativity
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
The art of project estimation
The art of project estimationThe art of project estimation
The art of project estimation
 
Successful interview for a young IT specialist
Successful interview for a young IT specialistSuccessful interview for a young IT specialist
Successful interview for a young IT specialist
 
Risk Management
Risk ManagementRisk Management
Risk Management
 
Resolving conflicts
Resolving conflictsResolving conflicts
Resolving conflicts
 

Recently uploaded

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 

Recently uploaded (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 

Anti patterns part 2

  • 1. Anti-patterns part 2 Dmitriy Kochergin, Developer Dnepropetrovsk, 2012 August 7, 2012 www.ExigenServices.com
  • 2. Content • Programming anti-patterns • Methodological anti-patterns • Configuration management anti-patterns 2 2 www.ExigenServices.com
  • 3. Part 1 Programming anti-patterns 3 3 www.ExigenServices.com
  • 4. Accidental complexity • Accidental complexity: Introducing unnecessary complexity into a solution • While essential complexity is inherent and unavoidable, accidental complexity is caused by the approach chosen to solve the problem – essential complexity: we have a hard problem – accidental complexity: we have made a problem hard – KISS principle 4 4 www.ExigenServices.com
  • 5. Accidental complexity • Solution: – Focus on the essential complexity – Avoid “tricky code” – After implementation check if your solution follow business problem 5 5 www.ExigenServices.com
  • 6. Accidental complexity 6 6 www.ExigenServices.com
  • 7. Blind faith • Blind faith (or blind programming): programmer develops a solution or fixes a computer bug and deploys it without testing • The programmer has blind faith in his abilities • Another form of blind faith is when a programmer calls a subroutine without checking the result (e.g. for null) 7 7 www.ExigenServices.com
  • 8. Boat anchor • Boat anchor refers to an unused piece of code that is left in code, typically for the reason "In case we need it later” • Problem: – hard to differentiate between obsolete code and working code – later it usually easier to rewrite method – uncommenting code can cause bugs • Use VCS to get old version if needed 8 8 www.ExigenServices.com
  • 9. Cargo cult programming • Cargo cult originally referred to aboriginal religions which grew up in the South Pacific after World War II • Cargo cult programming: Using patterns, technologies, frameworks without understanding why 9 9 www.ExigenServices.com
  • 10. Cargo cult programming 10 10 www.ExigenServices.com
  • 11. Coding by exception • Coding by exception: Adding new code to handle each special case when it appears • Typically happens due to covering new requirements • 'One-off' solutions decrease performance and maintainability • Try to generalize the special case first • Well designed software projects contain very few corner cases 11 11 www.ExigenServices.com
  • 12. Error hiding • Error hiding: catching an error message before it can be shown to the user and either showing nothing or showing a meaningless message • Cause: desire to hide complexity from the user • Solution: Raise an exception to the user with simplified error message, and save the full error message to an error log • User should understand what to do from error message, provide possible solutions 12 12 www.ExigenServices.com
  • 13. Hard coding • Hard coding: storing configuration data in source code rather than configuration files – configuration file path – mail server name – remote hosts – … other system environment variables • Program could work correctly only in certain environment (on developer machine) • Every new environment (including build servers) should be tuned to comply with hardcoded (predefined) structure 13 13 www.ExigenServices.com
  • 14. Hard coding • Solution: – obtain data from external sources – generate data – take it from user input – pass data through command line or system property 14 14 www.ExigenServices.com
  • 15. Soft coding • Soft coding: storing business logic in external resources rather than in source code • Example: storing business rules in DB • Reason: fear that the code we write will have to be changed as a result of a business rule change • Solution: avoid Hard Coding and Soft Coding 15 15 www.ExigenServices.com
  • 16. Magic numbers • Magic numbers: Including unexplained numbers in algorithms • Replace them with constants: • it is easier to read and understand • it is easier to alter the value of the number, as it is not duplicated • it helps detect typos 16 16 www.ExigenServices.com
  • 17. Spaghetti code • Spaghetti code: code that has a complex and tangled control structure, especially one using many GOTOs, exceptions, threads, or other "unstructured" branching constructs • Now term is used to describe any code with tangled and twisted logic, lots of branching, polymorphic behavior etc 17 17 www.ExigenServices.com
  • 18. Spaghetti code Un-structured code Well-structured code is a liability is an investment 18 18 www.ExigenServices.com
  • 19. Spaghetti code • Structured programming greatly decreased the incidence of spaghetti code: extensive use of subroutines, block structures and for and while loops • Functions not more than 10-20 rows • Use metrics to find spaghetti methods, e.g. cyclomatic complexity, method length. 19 19 www.ExigenServices.com
  • 20. Spaghetti code: Other related terms • Ravioli code: program structure is characterized by a number of small and (ideally) loosely-coupled components • While generally desirable from a coupling and cohesion perspective, overzealous separation and encapsulation of code can bloat call stacks and make navigation through the code more difficult 20 20 www.ExigenServices.com
  • 21. Shotgun surgery • Shotgun surgery: features are added to several places simultaneously, usually by copy-pasting with slight variations • Solution: Aspect oriented programming (AOP) 21 21 www.ExigenServices.com
  • 22. Shot in the Dark • Shot in the Dark: production (or test) environment poor track record leads to developers are guessing possible problems • “We can’t reproduce the problem in QA but I think it is caused by feature “X”” • Solution: Measure, Don’t Guess – local bug reproducing – error stack trace – profiler 22 22 www.ExigenServices.com
  • 23. Incorrect exceptions usage • Incorrect exceptions usage: normal program flow implemented using exceptions – exit from block using exception – similar to goto statement • Using exceptions to control program flow adds ambiguity • Solution: use exception only to inform program about errors. Checked – for recoverable errors, unchecked – for unrecoverable errors 23 23 www.ExigenServices.com
  • 24. Incorrect data • Incorrect data: could cause errors anytime during program execution • In contrast to program flow errors data errors are hardly exposed because data could be corrupted any stage earlier • Solution: – check data as early as possible – check input data of methods (design by contract and firewalls) 24 24 www.ExigenServices.com
  • 25. Lava flow • Lava flow: Retaining undesirable (redundant or low-quality) code because removing it is too expensive or has unpredictable consequences • If you leave tricky code – describe your solution in javadoc or comments • Write tests – then you will be confident in refactoring 25 25 www.ExigenServices.com
  • 26. Lava flow 26 26 www.ExigenServices.com
  • 27. Other programming anti- patterns • Busy waiting: consuming CPU while waiting for something to happen, usually by repeated checking instead of messaging • Negative cache is a cache that also stores "negative" responses (result indicating error). – e.g. when network was unavailable – cache error result, and return it even after network is back up. 27 27 www.ExigenServices.com
  • 28. Part 2 Methodological anti-patterns 28 28 www.ExigenServices.com
  • 29. Copy and paste programming • Copy-paste programming: describe highly repetitive code apparently produced by copy and paste operations • Use extract method refactoring 29 29 www.ExigenServices.com
  • 30. Copy and paste programming • Follow Don't Repeat Yourself (DRY) principle • modification of any element does not require a changes in other logically-unrelated elements 30 30 www.ExigenServices.com
  • 31. Golden hammer • Golden hammer (Maslow's hammer, law of the instrument): assuming that a favorite solution is universally applicable • “If all you have is a hammer, everything looks like a nail" Abraham Maslow, 1966 31 31 www.ExigenServices.com
  • 32. Golden hammer • Solution: – look at the problem from different points of view – choose technology (concept, framework or tool) that better suits to solve the problem – previous means you have o know at least on more solution to problem (learn it if needed) – There are 191 fundamental software patterns (23 Gamma Patterns + 17 Buschmann Patterns + 72 Analysis Patterns + 38 CORBA Design Patterns + 42 AntiPatterns) – [4] describes 140 antipatterns 32 32 www.ExigenServices.com
  • 33. Improbability factor • Improbability factor: assuming that known error is improbable to occur – programmers are aware of the problem – they are not allowed to fix the problem – because the chances of the problem ever appearing are supposedly negligible compared to other problems that could be solved with the programmers' time and money 33 33 www.ExigenServices.com
  • 34. Improbability factor • As a result, the problem may still occur and do heavy damage due to Murphy's law • Murphy's law typically stated as: "Anything that can go wrong, will go wrong” 34 34 www.ExigenServices.com
  • 35. Premature optimization • Premature optimization: Coding early-on for perceived efficiency, sacrificing good design, maintainability, and sometimes even real-world efficiency • "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil" Donald Knuth, 1974 • A simple and elegant design is often easier to optimize • In practice, it is often necessary to keep performance goals in mind when first designing software, but the programmer balances the goals of design and optimization 35 35 www.ExigenServices.com
  • 36. Premature pessimization • Premature pessimization: Coding early-on for good design, leaving performance intentionally low – multiple copying heavyweight container – recalculating rather than caching – etc • Solution should be optimal (not optimized) for task 36 36 www.ExigenServices.com
  • 37. Programming by permutation • Programming by permutation (or "programming by accident"): trying to find a solution by making small changes (permutations) to see if it works • Programmer trying to guess: – calls and order of procedures – parameters' values – etc. • Reason: – programmer does not fully understand the code or even don’t want to understand it – external module API is insufficiently documented 37 37 www.ExigenServices.com
  • 38. Programming by permutation • Problems: – new bugs can be introduced, leading to a "solution" that is even less correct than the starting point – it’s usually impossible to tell whether the solution will work for all cases – programming by permutation gives little or no assurance about the quality of the code produced 38 38 www.ExigenServices.com
  • 39. Reinventing the square wheel • Reinventing the square wheel: Failing to adopt an existing, adequate solution and instead creating a custom solution (reinventing the wheel) which performs much worse than the existing one (a square wheel). • Reason: – engineer doesn’t know the standard solution – engineer doesn’t like the standard solution – second-system effect 39 39 www.ExigenServices.com
  • 40. Reinventing the square wheel • Problems: – anyone starting from scratch, ignoring the prior art, will naturally face same old problems again – wasted development time, delaying a task – developers will have to support their solution, fixing bugs and adding new features 40 40 www.ExigenServices.com
  • 41. Part 3 Configuration management anti-patterns 41 41 www.ExigenServices.com
  • 42. Dependency hell • Dependency hell (DLL hell, JAR hell): problems with versions of required products • Problems: – many dependencies • high coupling – long chains of dependencies – conflicting dependencies • if different versions of lib cannot be simultaneously installed – circular dependencies • you can’t separate units by level of abstraction 42 42 www.ExigenServices.com
  • 43. Dependency hell • Solutions: – version numbering (major and minor versions) – smart package management (e.g. in Linux) • repository-based package management systems – software appliances (encapsulate dependencies in a one unit) – portable applications 43 43 www.ExigenServices.com
  • 44. THANKS FOR COMING!!! • My contacts: – e-mail: dmitriy.kochergin@exigenservices.com – Skype: dmitry.kochergin 44 44 www.ExigenServices.com
  • 45. Questions Questions? 45 45 www.ExigenServices.com
  • 46. Links Nr. Document Author, Date, Location [1] Anti-patterns wiki •http://en.wikipedia.org/wiki/Anti-patterns [2] AnemicDomainModel •http://www.martinfowler.com/bliki/AnemicDomainModel.html [3] AntiPatterns •http://www.antipatterns.com/briefing/sld001.htm [4] AntiPatterns catalog •http://c2.com/cgi-bin/wiki?AntiPatternsCatalog [5] Supported by the Antipattern template •http://c2.com/cgi-bin/wiki?AntiPatternTemplate [6] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J. Brown et.al. (Wiley) [7] AntiPatterns •http://sourcemaking.com/antipatterns 46 46 www.ExigenServices.com