SlideShare a Scribd company logo
ThoughtWorks


      the productive
programmer: practice
   10 ways to improve
            your code
             NEAL FORD        software architect / meme wrangler



                       ThoughtWorks
          nford@thoughtworks.com
          3003 Summit Boulevard, Atlanta, GA 30319
          www.nealford.com
          www.thoughtworks.com
          memeagora.blogspot.com
from whence?

         2 parts:

          mechanics

          practices
          practices
1   composed method
composed method
Divide your program into methods that
perform one identifiable task.


Keep all of the operations in a method at the
same level of abstraction.


This will naturally result in programs with many
small methods, each a few lines long.
refactoring to
composed method
BoundaryBase
 getDatabaseConnection()




           PartDb
populate()
getDatabaseConnection()
getDatabaseConnection()
createResultSet()
addPartToListFromResultSet()
BoundaryBase
 getDatabaseConnection()




             PartDb
populate()

createResultSet()
createResultSet()
addPartToListFromResultSet()
BoundaryBase




         PartDb
BoundaryBase
 getDatabaseConnection()
 getSqlForEntity()
 createResultSet()




             PartDb
populate()

getSqlForEntity()
addPartToListFromResultSet()
BoundaryBase
       BoundaryBase
                               getDatabaseConnection()
 getDatabaseConnection()
                               getSqlForEntity()
 getSqlForEntity()
                               createResultSet()
 createResultSet()
                               addEntityToListFromResultSet()
                               populate()



             PartDb                        PartDb
populate()
                               addEntityToListFromResultSet()
getSqlForEntity()              getSqlForEntity()
addPartToListFromResultSet()   addPartToListFromResultSet()
BoundaryBase
PartDb
benefits of composed
        method
shorter methods easier to test

method names become documentation

large number of very cohesive methods

discover reusable assets that you didn’t know
were there
2
     test-driven
    development
test-driven design
design benefits of tdd

first consumer


think about how the rest of the world uses this
class


creates consumption awareness
design benefits of tdd
forces mocking of dependent objects


naturally creates composed method


cleaner metrics
3
    static analysis
byte-code analysis:
     findbugs
bug categories
correctness
   probable bug


bad practice
   violation of recommended & essential
   coding practice

dodgy
  confusing, anomalous, written poorly
4   good citizenship
static methods


Math.sqrt(25)

                 Math.sqrt()
mixing static + state
singleton
singleton is bad because:

   mixes responsibilities

   untestable

   the object version of global variables
avoiding singletons
1. create a pojo for the business behavior

   simple

   testable!

2. create a factory to create the pojo

   also testable
5   yagni
    you ain’t gonna need it
discourages gold plating
build the simplest thing that we need right now

don’t indulge in speculative development

   increases software entropy

   only saves time if you can guarantee you
   won’t have to change it later

   leads to frameworks
This is just
what they need!
changeability

anticipatory
  design



                                refactorable




               rate of change

   lower                          higher
corporate code smells
6. We have an Architect who reviews all code pre-
checkin and decides whether or not to allow it
into version control.
7. We can’t use any open source code because
our lawyers say we can’t.
8. We use WebSphere because...(I always stop
listening at this point)
9. We bought the entire tool suite (even though
we only needed about 10% of it) because it was
cheaper than buying the individual tools.
10. We invented our own web/persistence/
messaging/caching framework because none of
the existing ones was good enough.
1. There is a reason that WSAD isn’t called
WHAPPY.
2. The initial estimate must be within 15% of the
final cost, the post-analysis estimate must be
within 10%, and the post-design estimate must be
with 5%
3. We don’t have time to write unit tests (we’re
spending too much time debugging)
4. We keep all of our business logic in stored
procedures...for performance reasons.
5. The only JavaDoc is the Eclipse message
explaining how to change your default JavaDoc
template.
6   question authority
angry monkeys
test names
testUpdateCacheAndVerifyThatItemExists() {

}

test_Update_cache_and_verify_that_item_exists() {

}
non-intuitive
pair programming
        studies




after adjusting, pairs produced code 15%
      more slowly than individuals...
pair programming
      studies




 ...with 15% fewer defects
7      slap

   single level of
abstraction principle
slap
keep all lines of code in a method at the same
level of abstraction
jumping abstraction layers makes code hard to
understand

composed method => slap

refactor to slap

even if it means single-line methods
8
polyglot


    

 
 
 
 
 


 
 
 
 
 
 programming
leveraging existing
platforms with languages
   targeted at specific
       problems and
        applications
looming problems/
       opportunities
massively parallel threading

   use a functional language: jaskell, scala

schedule pressure

   jruby on rails, grails
looming problems/
       opportunities

writing more declarative code via dsls

build fluent interfaces
swiby: jruby + swing
9   every nuance
java’s back alleys
reflection


   “reflection is slow”


   no longer true


elegant solutions to problems
regular expressions &
learn the nuances of
         java...
 ...then tell the other
people on your project
0   anti-objects
collaborative diffusion
“The metaphor of objects can go too far by making
us try to create objects that are too much inspired
by the real world. “


“...an antiobject is a kind of object that appears to
essentially do the opposite of what we generally
think the object should be doing.”
ThoughtWorks




                         questions?
   please fill out the session evaluations
slides & samples available at nealford.com


                                                         NEAL FORD        software architect / meme wrangler



                                                                   ThoughtWorks
 This work is licensed under the Creative Commons     nford@thoughtworks.com
                                                      3003 Summit Boulevard, Atlanta, GA 30319
 Attribution-Noncommercial-Share Alike 2.5 License.   www.nealford.com
                                                      www.thoughtworks.com
  http://creativecommons.org/licenses/by-nc-sa/2.5/   memeagora.blogspot.com
resources
An Initial Investigation of Test Driven Development in Industry -
Laurie Williams, Boby George
http://collaboration.csc.ncsu.edu/laurie/Papers/TDDpaperv8.pdf

findbugs
http://findbugs.sourceforge.net/

pmd/cpd
http://pmd.sourceforge.net/

The legend of the leaning tower
http://physicsworld.com/cws/article/print/16806

AntiPatterns Catalog
http://c2.com/cgi/wiki?AntiPatternsCatalog
resources
Smalltalk Best Practice Patterns Kent Beck
Prentice Hall PTR (October 13, 1996)
ISBN-10: 013476904X


Polyglot Programming
http://memeagora.blogspot.com/2006/12/polyglot-programming.html


Optical Illusions
http://en.wikipedia.org/wiki/Optical_illusion


Collaborative Diffusion: Programming
Anti-objects - A Repenning
http://www.cs.colorado.edu/~ralex/papers/PDF/OOPSLA06antiobjects.pdf
resources
       pair programming
http://c2.com/cgi/wiki?PairProgramming

http://www.xprogramming.com/Practices/PracPairs.html

http://collaboration.csc.ncsu.edu/laurie/Papers/
XPSardinia.PDF

http://www.cs.utah.edu/~lwilliam/Papers/
ieeeSoftware.PDF

More Related Content

What's hot

Quality of Bug Reports in Open Source
Quality of Bug Reports in Open SourceQuality of Bug Reports in Open Source
Quality of Bug Reports in Open Source
Thomas Zimmermann
 
Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)
vilniusjug
 
Automating Tactically vs Strategically SauceCon 2020
Automating Tactically vs Strategically SauceCon 2020Automating Tactically vs Strategically SauceCon 2020
Automating Tactically vs Strategically SauceCon 2020
Alan Richardson
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
satya sudheer
 
TDD Painkillers
TDD PainkillersTDD Painkillers
TDD Painkillers
Ben Hall
 
Devfest 2019-slides
Devfest 2019-slidesDevfest 2019-slides
Devfest 2019-slides
Alan Richardson
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOS
Pablo Villar
 
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
eduardomg23
 
Practical Guide to Unit Testing
Practical Guide to Unit TestingPractical Guide to Unit Testing
Practical Guide to Unit Testing
Krzysztof Szafranek
 
Do Bugs Reside in Complex Code?
Do Bugs Reside in Complex Code?Do Bugs Reside in Complex Code?
Do Bugs Reside in Complex Code?
CISPA Helmholtz Center for Information Security
 
Practical Test Automation Deep Dive
Practical Test Automation Deep DivePractical Test Automation Deep Dive
Practical Test Automation Deep Dive
Alan Richardson
 
Don't let your tests slow you down
Don't let your tests slow you downDon't let your tests slow you down
Don't let your tests slow you down
Daniel Irvine
 
Debugging
DebuggingDebugging
Debugging
Olivier Teytaud
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
Excella
 
Automating Strategically or Tactically when Testing
Automating Strategically or Tactically when TestingAutomating Strategically or Tactically when Testing
Automating Strategically or Tactically when Testing
Alan Richardson
 
PHPUnit - Unit testing
PHPUnit - Unit testingPHPUnit - Unit testing
PHPUnit - Unit testing
Nguyễn Đào Thiên Thư
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier
Christian Hujer
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
jexp
 

What's hot (19)

Quality of Bug Reports in Open Source
Quality of Bug Reports in Open SourceQuality of Bug Reports in Open Source
Quality of Bug Reports in Open Source
 
Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)Developer Tests - Things to Know (Vilnius JUG)
Developer Tests - Things to Know (Vilnius JUG)
 
Automating Tactically vs Strategically SauceCon 2020
Automating Tactically vs Strategically SauceCon 2020Automating Tactically vs Strategically SauceCon 2020
Automating Tactically vs Strategically SauceCon 2020
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
 
TDD Painkillers
TDD PainkillersTDD Painkillers
TDD Painkillers
 
Devfest 2019-slides
Devfest 2019-slidesDevfest 2019-slides
Devfest 2019-slides
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOS
 
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
Desenvolvendo um Framework com TDD - Um Diário de Bordo - Agile Trends 2014
 
Practical Guide to Unit Testing
Practical Guide to Unit TestingPractical Guide to Unit Testing
Practical Guide to Unit Testing
 
Do Bugs Reside in Complex Code?
Do Bugs Reside in Complex Code?Do Bugs Reside in Complex Code?
Do Bugs Reside in Complex Code?
 
Practical Test Automation Deep Dive
Practical Test Automation Deep DivePractical Test Automation Deep Dive
Practical Test Automation Deep Dive
 
Don't let your tests slow you down
Don't let your tests slow you downDon't let your tests slow you down
Don't let your tests slow you down
 
Debugging
DebuggingDebugging
Debugging
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
Automating Strategically or Tactically when Testing
Automating Strategically or Tactically when TestingAutomating Strategically or Tactically when Testing
Automating Strategically or Tactically when Testing
 
PHPUnit - Unit testing
PHPUnit - Unit testingPHPUnit - Unit testing
PHPUnit - Unit testing
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier
 
Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010Test Driven Development (TDD) Preso 360|Flex 2010
Test Driven Development (TDD) Preso 360|Flex 2010
 
Refactoring, 2nd Edition
Refactoring, 2nd EditionRefactoring, 2nd Edition
Refactoring, 2nd Edition
 

Similar to 10 Ways To Improve Your Code

Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
Thoughtworks
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
ThoughtWorks Studios
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
TobiasGoeschel
 
The Art Of Performance Tuning - with presenter notes!
The Art Of Performance Tuning - with presenter notes!The Art Of Performance Tuning - with presenter notes!
The Art Of Performance Tuning - with presenter notes!
Jonathan Ross
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
Yuri Visser
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12
Enkitec
 
Amplify your stack - Jsfoo pune 2012
Amplify your stack - Jsfoo pune 2012Amplify your stack - Jsfoo pune 2012
Amplify your stack - Jsfoo pune 2012
threepointone
 
Agile Development in .NET
Agile Development in .NETAgile Development in .NET
Agile Development in .NET
danhermes
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
Joe Ferguson
 
Rails in the Large - Neal Ford
Rails in the Large - Neal FordRails in the Large - Neal Ford
Rails in the Large - Neal Ford
Kmanthei
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
Mike Wilcox
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
Joe Ferguson
 
A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5
SSW
 
Passing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldPassing The Joel Test In The PHP World
Passing The Joel Test In The PHP World
Lorna Mitchell
 
Architecting a Large Software Project - Lessons Learned
Architecting a Large Software Project - Lessons LearnedArchitecting a Large Software Project - Lessons Learned
Architecting a Large Software Project - Lessons Learned
João Pedro Martins
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - Greach
HamletDRC
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?
Kasra Khosravi
 
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
Bill Scott
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Steven Pignataro
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
BlackRabbitCoder
 

Similar to 10 Ways To Improve Your Code (20)

Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
 
The Art Of Performance Tuning - with presenter notes!
The Art Of Performance Tuning - with presenter notes!The Art Of Performance Tuning - with presenter notes!
The Art Of Performance Tuning - with presenter notes!
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12
 
Amplify your stack - Jsfoo pune 2012
Amplify your stack - Jsfoo pune 2012Amplify your stack - Jsfoo pune 2012
Amplify your stack - Jsfoo pune 2012
 
Agile Development in .NET
Agile Development in .NETAgile Development in .NET
Agile Development in .NET
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 
Rails in the Large - Neal Ford
Rails in the Large - Neal FordRails in the Large - Neal Ford
Rails in the Large - Neal Ford
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5A modern architecturereview–usingcodereviewtools-ver-3.5
A modern architecturereview–usingcodereviewtools-ver-3.5
 
Passing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldPassing The Joel Test In The PHP World
Passing The Joel Test In The PHP World
 
Architecting a Large Software Project - Lessons Learned
Architecting a Large Software Project - Lessons LearnedArchitecting a Large Software Project - Lessons Learned
Architecting a Large Software Project - Lessons Learned
 
New Ideas for Old Code - Greach
New Ideas for Old Code - GreachNew Ideas for Old Code - Greach
New Ideas for Old Code - Greach
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?
 
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
 

More from ConSanFrancisco123

Open Ap Is State Of The Market
Open Ap Is State Of The MarketOpen Ap Is State Of The Market
Open Ap Is State Of The Market
ConSanFrancisco123
 
Yahoo Pipes Middleware In The Cloud
Yahoo Pipes Middleware In The CloudYahoo Pipes Middleware In The Cloud
Yahoo Pipes Middleware In The Cloud
ConSanFrancisco123
 
Ruby V Ms A Comparison
Ruby V Ms A ComparisonRuby V Ms A Comparison
Ruby V Ms A Comparison
ConSanFrancisco123
 
Yellowpagescom Behind The Curtain
Yellowpagescom Behind The CurtainYellowpagescom Behind The Curtain
Yellowpagescom Behind The Curtain
ConSanFrancisco123
 
Teamwork Is An Individual Skill How To Build Any Team Any Time
Teamwork Is An Individual Skill How To Build Any Team Any TimeTeamwork Is An Individual Skill How To Build Any Team Any Time
Teamwork Is An Individual Skill How To Build Any Team Any Time
ConSanFrancisco123
 
Agility Possibilities At A Personal Level
Agility Possibilities At A Personal LevelAgility Possibilities At A Personal Level
Agility Possibilities At A Personal Level
ConSanFrancisco123
 
Res Tful Enterprise Development
Res Tful Enterprise DevelopmentRes Tful Enterprise Development
Res Tful Enterprise Development
ConSanFrancisco123
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
ConSanFrancisco123
 
Http Status Report
Http Status ReportHttp Status Report
Http Status Report
ConSanFrancisco123
 
Behind The Scenes At My Spacecom
Behind The Scenes At My SpacecomBehind The Scenes At My Spacecom
Behind The Scenes At My Spacecom
ConSanFrancisco123
 
Building Blueprint With Gwt
Building Blueprint With GwtBuilding Blueprint With Gwt
Building Blueprint With Gwt
ConSanFrancisco123
 
Security Cas And Open Id
Security Cas And Open IdSecurity Cas And Open Id
Security Cas And Open Id
ConSanFrancisco123
 
Soa And Web Services Security
Soa And Web Services SecuritySoa And Web Services Security
Soa And Web Services Security
ConSanFrancisco123
 
Making Threat Modeling Useful To Software Development
Making Threat Modeling Useful To Software DevelopmentMaking Threat Modeling Useful To Software Development
Making Threat Modeling Useful To Software Development
ConSanFrancisco123
 
Secure Programming With Static Analysis
Secure Programming With Static AnalysisSecure Programming With Static Analysis
Secure Programming With Static Analysis
ConSanFrancisco123
 
Agile Software Development In The Large
Agile Software Development In The LargeAgile Software Development In The Large
Agile Software Development In The Large
ConSanFrancisco123
 
Introduction Challenges In Agile And How To Overcome Them
Introduction Challenges In Agile And How To Overcome ThemIntroduction Challenges In Agile And How To Overcome Them
Introduction Challenges In Agile And How To Overcome Them
ConSanFrancisco123
 
Business Natural Languages Development In Ruby
Business Natural Languages Development In RubyBusiness Natural Languages Development In Ruby
Business Natural Languages Development In Ruby
ConSanFrancisco123
 
Orbitz World Wide An Architectures Response To Growth And Change
Orbitz World Wide An Architectures Response To Growth And ChangeOrbitz World Wide An Architectures Response To Growth And Change
Orbitz World Wide An Architectures Response To Growth And Change
ConSanFrancisco123
 
Introduction Architectures Youve Always Wondered About
Introduction Architectures Youve Always Wondered AboutIntroduction Architectures Youve Always Wondered About
Introduction Architectures Youve Always Wondered About
ConSanFrancisco123
 

More from ConSanFrancisco123 (20)

Open Ap Is State Of The Market
Open Ap Is State Of The MarketOpen Ap Is State Of The Market
Open Ap Is State Of The Market
 
Yahoo Pipes Middleware In The Cloud
Yahoo Pipes Middleware In The CloudYahoo Pipes Middleware In The Cloud
Yahoo Pipes Middleware In The Cloud
 
Ruby V Ms A Comparison
Ruby V Ms A ComparisonRuby V Ms A Comparison
Ruby V Ms A Comparison
 
Yellowpagescom Behind The Curtain
Yellowpagescom Behind The CurtainYellowpagescom Behind The Curtain
Yellowpagescom Behind The Curtain
 
Teamwork Is An Individual Skill How To Build Any Team Any Time
Teamwork Is An Individual Skill How To Build Any Team Any TimeTeamwork Is An Individual Skill How To Build Any Team Any Time
Teamwork Is An Individual Skill How To Build Any Team Any Time
 
Agility Possibilities At A Personal Level
Agility Possibilities At A Personal LevelAgility Possibilities At A Personal Level
Agility Possibilities At A Personal Level
 
Res Tful Enterprise Development
Res Tful Enterprise DevelopmentRes Tful Enterprise Development
Res Tful Enterprise Development
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
Http Status Report
Http Status ReportHttp Status Report
Http Status Report
 
Behind The Scenes At My Spacecom
Behind The Scenes At My SpacecomBehind The Scenes At My Spacecom
Behind The Scenes At My Spacecom
 
Building Blueprint With Gwt
Building Blueprint With GwtBuilding Blueprint With Gwt
Building Blueprint With Gwt
 
Security Cas And Open Id
Security Cas And Open IdSecurity Cas And Open Id
Security Cas And Open Id
 
Soa And Web Services Security
Soa And Web Services SecuritySoa And Web Services Security
Soa And Web Services Security
 
Making Threat Modeling Useful To Software Development
Making Threat Modeling Useful To Software DevelopmentMaking Threat Modeling Useful To Software Development
Making Threat Modeling Useful To Software Development
 
Secure Programming With Static Analysis
Secure Programming With Static AnalysisSecure Programming With Static Analysis
Secure Programming With Static Analysis
 
Agile Software Development In The Large
Agile Software Development In The LargeAgile Software Development In The Large
Agile Software Development In The Large
 
Introduction Challenges In Agile And How To Overcome Them
Introduction Challenges In Agile And How To Overcome ThemIntroduction Challenges In Agile And How To Overcome Them
Introduction Challenges In Agile And How To Overcome Them
 
Business Natural Languages Development In Ruby
Business Natural Languages Development In RubyBusiness Natural Languages Development In Ruby
Business Natural Languages Development In Ruby
 
Orbitz World Wide An Architectures Response To Growth And Change
Orbitz World Wide An Architectures Response To Growth And ChangeOrbitz World Wide An Architectures Response To Growth And Change
Orbitz World Wide An Architectures Response To Growth And Change
 
Introduction Architectures Youve Always Wondered About
Introduction Architectures Youve Always Wondered AboutIntroduction Architectures Youve Always Wondered About
Introduction Architectures Youve Always Wondered About
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 

10 Ways To Improve Your Code

  • 1. ThoughtWorks the productive programmer: practice 10 ways to improve your code NEAL FORD software architect / meme wrangler ThoughtWorks nford@thoughtworks.com 3003 Summit Boulevard, Atlanta, GA 30319 www.nealford.com www.thoughtworks.com memeagora.blogspot.com
  • 2.
  • 3. from whence? 2 parts: mechanics practices practices
  • 4. 1 composed method
  • 5.
  • 6. composed method Divide your program into methods that perform one identifiable task. Keep all of the operations in a method at the same level of abstraction. This will naturally result in programs with many small methods, each a few lines long.
  • 8.
  • 9.
  • 10. BoundaryBase getDatabaseConnection() PartDb populate() getDatabaseConnection() getDatabaseConnection() createResultSet() addPartToListFromResultSet()
  • 11. BoundaryBase getDatabaseConnection() PartDb populate() createResultSet() createResultSet() addPartToListFromResultSet()
  • 12. BoundaryBase PartDb
  • 13. BoundaryBase getDatabaseConnection() getSqlForEntity() createResultSet() PartDb populate() getSqlForEntity() addPartToListFromResultSet()
  • 14.
  • 15.
  • 16. BoundaryBase BoundaryBase getDatabaseConnection() getDatabaseConnection() getSqlForEntity() getSqlForEntity() createResultSet() createResultSet() addEntityToListFromResultSet() populate() PartDb PartDb populate() addEntityToListFromResultSet() getSqlForEntity() getSqlForEntity() addPartToListFromResultSet() addPartToListFromResultSet()
  • 19. benefits of composed method shorter methods easier to test method names become documentation large number of very cohesive methods discover reusable assets that you didn’t know were there
  • 20. 2 test-driven development test-driven design
  • 21. design benefits of tdd first consumer think about how the rest of the world uses this class creates consumption awareness
  • 22. design benefits of tdd forces mocking of dependent objects naturally creates composed method cleaner metrics
  • 23. 3 static analysis
  • 24. byte-code analysis: findbugs
  • 25. bug categories correctness probable bug bad practice violation of recommended & essential coding practice dodgy confusing, anomalous, written poorly
  • 26.
  • 27.
  • 28. 4 good citizenship
  • 30. mixing static + state singleton singleton is bad because: mixes responsibilities untestable the object version of global variables
  • 31. avoiding singletons 1. create a pojo for the business behavior simple testable! 2. create a factory to create the pojo also testable
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. 5 yagni you ain’t gonna need it
  • 37. discourages gold plating build the simplest thing that we need right now don’t indulge in speculative development increases software entropy only saves time if you can guarantee you won’t have to change it later leads to frameworks
  • 38.
  • 39. This is just what they need!
  • 40.
  • 41. changeability anticipatory design refactorable rate of change lower higher
  • 43. 6. We have an Architect who reviews all code pre- checkin and decides whether or not to allow it into version control. 7. We can’t use any open source code because our lawyers say we can’t. 8. We use WebSphere because...(I always stop listening at this point) 9. We bought the entire tool suite (even though we only needed about 10% of it) because it was cheaper than buying the individual tools. 10. We invented our own web/persistence/ messaging/caching framework because none of the existing ones was good enough.
  • 44. 1. There is a reason that WSAD isn’t called WHAPPY. 2. The initial estimate must be within 15% of the final cost, the post-analysis estimate must be within 10%, and the post-design estimate must be with 5% 3. We don’t have time to write unit tests (we’re spending too much time debugging) 4. We keep all of our business logic in stored procedures...for performance reasons. 5. The only JavaDoc is the Eclipse message explaining how to change your default JavaDoc template.
  • 45. 6 question authority
  • 49.
  • 50. pair programming studies after adjusting, pairs produced code 15% more slowly than individuals...
  • 51. pair programming studies ...with 15% fewer defects
  • 52. 7 slap single level of abstraction principle
  • 53. slap keep all lines of code in a method at the same level of abstraction jumping abstraction layers makes code hard to understand composed method => slap refactor to slap even if it means single-line methods
  • 54.
  • 55.
  • 56. 8 polyglot programming
  • 57. leveraging existing platforms with languages targeted at specific problems and applications
  • 58. looming problems/ opportunities massively parallel threading use a functional language: jaskell, scala schedule pressure jruby on rails, grails
  • 59. looming problems/ opportunities writing more declarative code via dsls build fluent interfaces
  • 60. swiby: jruby + swing
  • 61.
  • 62. 9 every nuance
  • 63. java’s back alleys reflection “reflection is slow” no longer true elegant solutions to problems
  • 64.
  • 65.
  • 66.
  • 68.
  • 69. learn the nuances of java... ...then tell the other people on your project
  • 70. 0 anti-objects
  • 71. collaborative diffusion “The metaphor of objects can go too far by making us try to create objects that are too much inspired by the real world. “ “...an antiobject is a kind of object that appears to essentially do the opposite of what we generally think the object should be doing.”
  • 72.
  • 73.
  • 74. ThoughtWorks questions? please fill out the session evaluations slides & samples available at nealford.com NEAL FORD software architect / meme wrangler ThoughtWorks This work is licensed under the Creative Commons nford@thoughtworks.com 3003 Summit Boulevard, Atlanta, GA 30319 Attribution-Noncommercial-Share Alike 2.5 License. www.nealford.com www.thoughtworks.com http://creativecommons.org/licenses/by-nc-sa/2.5/ memeagora.blogspot.com
  • 75. resources An Initial Investigation of Test Driven Development in Industry - Laurie Williams, Boby George http://collaboration.csc.ncsu.edu/laurie/Papers/TDDpaperv8.pdf findbugs http://findbugs.sourceforge.net/ pmd/cpd http://pmd.sourceforge.net/ The legend of the leaning tower http://physicsworld.com/cws/article/print/16806 AntiPatterns Catalog http://c2.com/cgi/wiki?AntiPatternsCatalog
  • 76. resources Smalltalk Best Practice Patterns Kent Beck Prentice Hall PTR (October 13, 1996) ISBN-10: 013476904X Polyglot Programming http://memeagora.blogspot.com/2006/12/polyglot-programming.html Optical Illusions http://en.wikipedia.org/wiki/Optical_illusion Collaborative Diffusion: Programming Anti-objects - A Repenning http://www.cs.colorado.edu/~ralex/papers/PDF/OOPSLA06antiobjects.pdf
  • 77. resources pair programming http://c2.com/cgi/wiki?PairProgramming http://www.xprogramming.com/Practices/PracPairs.html http://collaboration.csc.ncsu.edu/laurie/Papers/ XPSardinia.PDF http://www.cs.utah.edu/~lwilliam/Papers/ ieeeSoftware.PDF