SlideShare une entreprise Scribd logo
1  sur  138
Télécharger pour lire hors ligne
Simple Design Applied
    Spend more time creating
         valuable code



Alistair McKinnell   Declan Whelan
    @mckinnell         @dwhelan
Exercise
What is Simple Design?

 On an index card write up to
 three facts on an index card.

    Be ready to share with
          your table.
What is Simple Design?

 At your table gather the facts
 and count how many distinct
    facts you came up with.
Introductions



      ?
www.XProgramming.com
Exercise
Simple Design

At your table order the
rules of simple design in
      priority order.
Simple Design

1. All tests must pass
2. No code is duplicated
3. Code is self-explanatory
4. No superfluous parts exist
Simple Design

1. All tests must pass
2. No code is duplicated
3. Code is self-explanatory
4. No superfluous parts exist
Simple Design

1. Passes its tests
2. No code is duplicated
3. Code is self-explanatory
4. No superfluous parts exist
Simple Design

1. Passes its tests
2. Minimizes duplication
3. Code is self-explanatory
4. No superfluous parts exist
Simple Design

1. Passes its tests
2. Minimizes duplication
3. Maximizes clarity
4. No superfluous parts exist
Simple Design

1. Passes its tests
2. Minimizes duplication
3. Maximizes clarity
4. Has fewer elements
Simple Design

1. Passes its tests (given TDD)
2. Minimizes duplication
3. Maximizes clarity
4. Has fewer elements
Simple Design

1. Passes its tests (given TDD)
2. Minimizes duplication
3. Maximizes clarity (fix names)
4. Has fewer elements
Simple Design

1. Passes its tests (given TDD)
2. Minimizes duplication
3. Maximizes clarity (fix names)
4. Has fewer elements
That leaves me with two key elements
of simple design: remove duplication and
fix bad names.
When I remove duplication, I tend to see
an appropriate structure emerge, and when
I fix bad names, I tend to see responsibilities
slide into appropriate parts of the design.


                          J. B. Rainsberger
Simple Design

• Remove duplication
• Fix bad names
Simple Design
       (for today)
• Fix bad names

    ❤    Choosing good names

• Remove duplication

    ❤    Commonality & Variability
Exercise
Stroop Effect
 Green Red Blue
Purple Blue Purple
 Green Red Blue
Purple Blue Purple
 Blue Purple Red
Green Purple Green
Meaning:




Colour:
           black
           yellow
Meaning:




Colour:
           blue
           black
black
yellow
yellow
 red
red
yellow
red
yellow
blue
blue
yellow
 blue
red
red
blue
red
yellow
yellow
red
yellow
red
yellow
blue
black
yellow
black
black
blue
red
black
The
End
Exercise
CComBstr sVal                                 $.getJSON()                                        int result




                Rx rx                   applyMeasureConstraintToEnableSortingByMeasure()                     float hp




    applyPhq9DateRangeConstraint()                      public void run()                                Date genymdhms




               m_name                                      Label label                                    IShapeFactory




              Customer                                        int i                        RollOverPerformanceIndicatorsToNextMonthTask




          CustomerManager                              LPSTR lpCmdLine                               int daysSinceModification




          boolean fNewPage                      UpdatePerfIndValueDecCountCmd                  DepressionSelfManagementCalculator



                                                             Tutorial02

PerfIndValueDecCountForMatchingIvpCmd                    PulseRenderer                               IndexCardPageLayout sut
CComBstr sVal                                 $.getJSON()                                        int result




                Rx rx                   applyMeasureConstraintToEnableSortingByMeasure()                     float hp




    applyPhq9DateRangeConstraint()                      public void run()                                Date genymdhms




               m_name                                      Label label                                    IShapeFactory




              Customer                                        int i                        RollOverPerformanceIndicatorsToNextMonthTask




          CustomerManager                              LPSTR lpCmdLine                               int daysSinceModification




          boolean fNewPage                      UpdatePerfIndValueDecCountCmd                  DepressionSelfManagementCalculator



                                                             Tutorial02

PerfIndValueDecCountForMatchingIvpCmd                    PulseRenderer                               IndexCardPageLayout sut
Find a partner and each of you:

1. select a name you thought was good
2. explain why to your partner
3. select a name you thought was bad
4. explain why to your partner
                                      CComBstr sVal                                 $.getJSON()                                        int result




                                          Rx rx                   applyMeasureConstraintToEnableSortingByMeasure()                     float hp




                              applyPhq9DateRangeConstraint()                      public void run()                                Date genymdhms




                                         m_name                                      Label label                                    IShapeFactory




                                        Customer                                        int i                        RollOverPerformanceIndicatorsToNextMonthTask




                                    CustomerManager                              LPSTR lpCmdLine                               int daysSinceModification




                                    boolean fNewPage                      UpdatePerfIndValueDecCountCmd                  DepressionSelfManagementCalculator




                          PerfIndValueDecCountForMatchingIvpCmd                    PulseRenderer                               IndexCardPageLayout sut
Choosing Good Names
Choosing Good Names
    Use the telephone test for readability.
    If someone could understand your
    code when read aloud over the
    telephone, it's clear enough.
    If not, then it needs rewriting.
Telephone Test


Goal Donor vs Gold Owner

  Date genymdhms
Choosing Good Names
    Splitters can be lumped more easily
    than lumpers can be split.
    It is easier to combine two concepts
    that it is to separate them.
Splitting a Lumper

 Customer Address
Splitting a Lumper

                  Customer Address




Billing Address     Mailing Address   Service Address
Lumping a Splitter

Billing Address   Mailing Address   Service Address
Lumping a Splitter

Billing Address   Mailing Address    Service Address




                  Customer Address
Choosing Good Names

    Pronounceable Names
    Avoid Encodings
Pronounceable Names

UpdatePerfIndValueDecCountCmd
Pronounceable Names

UpdatePerfIndValueDecCountCmd


DecrementAggregateCommand
Pronounceable Names

Date genymdhms
Pronounceable Names

Date genymdhms


Date generatedTimestamp
Avoid Encodings

LPSTR lpCmdLine
LPSTR commandLine

m_name
name
Choosing Good Names

    Intention-Revealing Name
    Role-Suggesting Name
Intention-Revealing Name

applyMeasureConstraintTo
    EnableSortingByMeasure()
Intention-Revealing Name

applyMeasureConstraintTo
    EnableSortingByMeasure()

applyMeasureConstraint()
Role-Suggesting Name

int result


IndexCardPageLayout sut
Choosing Good Names


    Ubiquitous Language
Ubiquitous Language

CComBstr sVal
Ubiquitous Language

CComBstr sVal


CComBstr calibrationToolName
Ubiquitous Language

Rx rx
Ubiquitous Language

Rx rx


Rx refillable
Ubiquitous Language

applyPhq9DateRangeConstraint()


The PHQ-9 is the nine item depression scale of
the Patient Health Questionnaire.

The PHQ-9 is a powerful tool for assisting primary
care clinicians in diagnosing depression as well as
selecting and monitoring treatment.
Pragmatic
            Programmers                                 Agile in a Flash
                                                                  Speed-Learning Agile
                                                                 Software Development

                                                                                       Agile Cards for
                                                                                         Agile Teams




                                                                                       Jeff Langr and
                                                                                         Tim Ottinger
                                                                                      edited by Susannah Pfalzer



Prepared exclusively for Alistair McKinnell   Copyright ©2011 Pragmatic Programmers
43            Really Meaningful Names


               ® Are accurate
               ® Are purposeful
               ® Are pronounceable
               ® Begin well
               ® Are simple
               ® Depend on context
               ® Match name length to scope




Prepared exclusively for Alistair McKinnell   Copyright ©2011 Pragmatic Programmers
Choosing Good Names
                                                                                                     •Locate one
                             Naming'Guidelines
System'of'Names
    S1# #   Name#pass#the#“telephone”#test.
    S2# #   There#is#a#clean#name#for#each#concept.#Remember:#later#on#it’s#easier#to#lump#




                                                                                                      guideline that if
            things#together#than#to#split#them#apart.
    S3# #   Name#is#from#the#problem#or#solu?on#domain#and#support#ubiquitous#language#for#
            the#team

General



                                                                                                      applied would have
    G1##    Name#is#pronounceable.
    G2##    Name#avoids#encodings#and#member#prefixes.
    G3##    Name#suggest#why#it#exists.
    G4##    Name#suggest#how#it#should#be#used.




                                                                                                      the biggest impact
    G5##    Name#suggest#what#it#does.
    G6##    Name#is#easily#searchable#in#the#code#base.


Classes
    C1#     If#this#is#an#important#base#class#its#class#name#should#be#a#simple#single#word.
    C2#
    C3#
            If#this#is#a#subclass#its#class#name#suggests#how#it#differs#from#its#superclass.
            The#class#name#is#a#noun#or#a#noun#phrase.
                                                                                                      on your code
                                                                                                     •Find a partner
Methods
    M1#     The#method#name#suggests#why#it#would#be#called.
    M2#     The#method#is#name#a#verb#or#a#verb#phrase.


Variables/Fields/Arguments



                                                                                                     •Discuss
    V1#     Its#name#indicate#the#role#it's#playing.
    V2#     The#length#of#the#name#reflect#its#scope.


Alistair McKinnell @amckinnell Declan Whelan @dwhelan
Naming Guidelines v1.0 August 2012 !                                                           1/1
Choosing Good Names
public List<int[]> getThem() {
  List<int[]> list1 = new ArrayList<int[]>();

    for (int[] x : theList)
      if (x[0] == 4)
        list1.add(x);

    return list1;
}




Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, pages 18-19
Choosing Good Names
public List<int[]> getThem() {
  List<int[]> list1 = new ArrayList<int[]>();

    for (int[] x : theList)
      if (x[0] == 4)
        list1.add(x);

    return list1;
}

public List<int[]> getFlaggedCells() {
  List<int[]> flaggedCells = new ArrayList<int[]>();

    for (int[] cell : gameBoard)
      if (cell[STATUS_VALUE] == FLAGGED)
        flaggedCells.add(cell);

    return flaggedCells;
}

Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, pages 18-19
Choosing Good Names
public List<int[]> getThem() {
  List<int[]> list1 = new ArrayList<int[]>();

    for (int[] x : theList)
      if (x[0] == 4)
        list1.add(x);

    return list1;
}

public List<Cell> getFlaggedCells() {
  List<Cell> flaggedCells = new ArrayList<Cell>();

    for (Cell cell : gameBoard)
      if (cell.isFlagged())
        flaggedCells.add(cell);

    return flaggedCells;
}

Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, pages 18-19
Choosing Good Names
public List<int[]> getThem() {
  List<int[]> list1 = new ArrayList<int[]>();

    for (int[] x : theList)
      if (x[0] == 4)
        list1.add(x);

    return list1;
}

public List<Cell> getFlaggedCells() {
  List<Cell> result = new ArrayList<Cell>();

    for (Cell cell : gameBoard)
      if (cell.isFlagged())
        result.add(cell);

    return result;
}

Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, pages 18-19
Choosing Good Names
int s = 0;

for (int j=0; j<34; j++) {
  s += (t[j]*4)/5;
}


const int EFFECTIVE_DAYS_PER_WEEK = 4;
int realDaysPerIdealDay = 4;
const int WORKING_DAYS_PER_WEEK = 5;
const int WORK_DAYS_PER_WEEK = 5;
int sum = 0;
int effectiveTotalEstimate = 0;
for (int j=0; j < NUMBER_OF_TASKS; j++) {
for (int j=0; j < NUMBER_OF_TASKS; j++) {realDaysPerIdealDay;
  int realTaskDays = taskEstimate[j] *
  int effectiveTaskEstimate =
  int realTaskWeeks = (realdays / WORK_DAYS_PER_WEEK);
    taskEstimate[j] * EFFECTIVE_DAYS_PER_WEEK / WORKING_DAYS_PER_WEEK;
  sum += realTaskWeeks;
  effectiveTotalEstimate += effectiveTaskEstimate;
}
}



        Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, page 23
What’s In A Name?


   Moonbeam
    Zappa
All tests must pass       No code is duplicated




Code is self-explanatory   No superfluous parts exist
No code is duplicated
Exercise
How do you handle
   duplicate code
 in your codebase?
Avoiding Duplicate Code

     DRY: Don’t Repeat Yourself
     Every piece of knowledge must have
     a single, unambiguous, authoritative
     representation within a system.
Avoiding Duplicate Code

     Once and Only Once
     Data, structure, or logic should exist
     in only one place in the system.
Avoiding Duplicate Code

     Test-Driven Development
     1. Write new code only if an
        automated test has failed.
     2. Eliminate duplication.
Avoiding Duplicate Code

     Single Choice Principle
     Whenever a software system must
     support a set of alternatives, one
     and only one module in the system
     should know their exhaustive list.
Avoiding Duplicate Code

     Duplication may be the
     root of all evil in software.
Commonality and Variability
Copy & Paste
function something() {



}
function something() {




}


function something() {




}
function something() {




}


function somethingElse() {




}
function something() {




}


function somethingElse() {




}
Duplicate Code
Copy & Paste
Edit the Copy
                ☞ Duplicate Code
Duplicate Code

Avoid duplication by expressing
  commonality and variability
           explicitly.
function something() {




}


function somethingElse() {




}
Duplicate Code:
Select Options
Can you spot the
   commonality and variation?

Can you spot the duplicate code?

   How would you make the
commonality and variation explicit?
public static List<SelectOption> createEndMonthList(Date expiryDate) {
    int selectedMonth = getDateMonth(expiryDate);

    SelectOptionsSource months = new SelectOptionsSource(1, 12, selectedMonth);
    SelectOptions monthOptions = new SelectOptions(months);

    return monthOptions.create();
}

public static List<SelectOption> createEndDaysList() {
    int selectedDay = getDateDay(getCurrentDatePlus14Days());

    SelectOptionsSource days = new SelectOptionsSource(1, 31, selectedDay);
    SelectOptions dayOptions = new SelectOptions(days);

    return dayOptions.create();
}

public static List<SelectOption> createEndYearList() {
    int selectedYear = getDateYear(getCurrentDatePlus14Days());

    SelectOptionsSource years = new SelectOptionsSource(1985, 1985 + 30, selectedYear);
    SelectOptions yearOptions = new SelectOptions(years);

    return yearOptions.create();
}
public static List<SelectOption> createEndMonthList(Date expiryDate) {
    int selectedMonth = getDateMonth(expiryDate);

    SelectOptionsSource months = new SelectOptionsSource(1, 12, selectedMonth);
    SelectOptions monthOptions = new SelectOptions(months);

    return monthOptions.create();
}

public static List<SelectOption> createEndDaysList() {
    int selectedDay = getDateDay(getCurrentDatePlus14Days());

    SelectOptionsSource days = new SelectOptionsSource(1, 31, selectedDay);
    SelectOptions dayOptions = new SelectOptions(days);

    return dayOptions.create();
}

public static List<SelectOption> createEndYearList() {
    int selectedYear = getDateYear(getCurrentDatePlus14Days());

    SelectOptionsSource years = new SelectOptionsSource(1985, 1985 + 30, selectedYear);
    SelectOptions yearOptions = new SelectOptions(years);

    return yearOptions.create();
}
public static List<SelectOption> createEndMonthList(Date expiryDate) {
    int selectedMonth = getDateMonth(expiryDate);

    SelectOptionsSource months = new SelectOptionsSource(1, 12, selectedMonth);
    SelectOptions monthOptions = new SelectOptions(months);

    return monthOptions.create();
}

public static List<SelectOption> createEndDaysList() {
    int selectedDay = getDateDay(getCurrentDatePlus14Days());

    SelectOptionsSource days = new SelectOptionsSource(1, 31, selectedDay);
    SelectOptions dayOptions = new SelectOptions(days);

    return dayOptions.create();
}

public static List<SelectOption> createEndYearList() {
    int selectedYear = getDateYear(getCurrentDatePlus14Days());

    SelectOptionsSource years = new SelectOptionsSource(1985, 1985 + 30, selectedYear);
    SelectOptions yearOptions = new SelectOptions(years);

    return yearOptions.create();
}
Select Options
           SelectOptions                      SelectOptionsSource

create()                                  getFirst()
                                          getLast()
                                          isSelected()




     Commonality            Variability                  Resolution
                                                         Encapsulate
       Behaviour           Collaborator
                                                          Collection
Select Options
           SelectOptions                       SelectOptionsSource

create()                                   getFirst()
                                           getLast()
                                           isSelected()




     Commonality             Variability                  Resolution

    Data Structure         Value of State            Simple Java Type
Select Options
           SelectOptions               SelectOptionsSource

create()                           getFirst()
                                   getLast()
                                   isSelected()




                           Encapsulate
                           Collection
Select Options
           SelectOptions               SelectOptionsSource

create()                          getFirst()
                                  getLast()
                                  isSelected()




                           Parameter
                           Object
Duplicate Code:
Compound Result Handler
Can you spot the
   commonality and variation?

Can you spot the duplicate code?

   How would you make the
commonality and variation explicit?
if ( ... ) {




} else {




}
Compound Result Handler
    CompoundResultHandler                CompoundResultClassifier

                                        isNegative()
                                        isPositive()




                                     AbstractCompoundResultClassifier

                                     toNumber()




                  QueensCompoundResultClassifier            StandardCompoundResultClassifier

                 isNegative()                             isNegative()
                 isPositive()                             isPositive()
Compound Result Handler
    CompoundResultHandler                CompoundResultClassifier

                                        isNegative()
                                        isPositive()




                                     AbstractCompoundResultClassifier

                                     toNumber()




                  QueensCompoundResultClassifier            StandardCompoundResultClassifier

                 isNegative()                             isNegative()
                 isPositive()                             isPositive()
Compound Result Handler
      CompoundResultHandler                CompoundResultClassifier

                                          isNegative()
                                          isPositive()




                                       AbstractCompoundResultClassifier

                                       toNumber()




                    QueensCompoundResultClassifier            StandardCompoundResultClassifier

                   isNegative()                             isNegative()
                   isPositive()                             isPositive()




 Commonality                         Variability                                Resolution
                                                                              Inheritance
  Behaviour                       Implementation
                                                                           (Object-Oriented)
Compound Result Handler
      CompoundResultHandler                CompoundResultClassifier

                                          isNegative()
                                          isPositive()




                                       AbstractCompoundResultClassifier

                                       toNumber()




                    QueensCompoundResultClassifier            StandardCompoundResultClassifier

                   isNegative()                             isNegative()
                   isPositive()                             isPositive()




 Commonality                         Variability                                Resolution
                                                                              Inheritance
  Behaviour                       Implementation
                                                                           (Object-Oriented)
Compound Result Handler
        CompoundResultHandler                CompoundResultClassifier

                                            isNegative()
                                            isPositive()




                                         AbstractCompoundResultClassifier

                                         toNumber()




                      QueensCompoundResultClassifier            StandardCompoundResultClassifier

                     isNegative()                             isNegative()
                     isPositive()                             isPositive()




 Commonality                           Variability                                Resolution

 Implementation                            None                                   Base Class
Compound Result Handler
        CompoundResultHandler                CompoundResultClassifier

                                            isNegative()
                                            isPositive()




                                         AbstractCompoundResultClassifier

                                         toNumber()




                      QueensCompoundResultClassifier            StandardCompoundResultClassifier

                     isNegative()                             isNegative()
                     isPositive()                             isPositive()




 Commonality                           Variability                                Resolution

 Implementation                            None                                   Base Class
Compound Result Handler
public static CompoundResultClassifier createCompoundResultClassifier(
                                                Patient sourcePatient) {
    return isRegisteredAtQueens(sourcePatient) ? QUEENS : STANDARD;
}

private static boolean isRegisteredAtQueens(Patient sourcePatient) {
    return sourcePatient.getDataWarehouse().equals(DataWarehouseTag.QHN);
}




                          Factory
Avoiding Duplicate Code
Commonality and Variability
Duplicate Code
Copy & Paste
Edit the Copy
                ☞ Duplicate Code
Duplicate Code

Avoid duplication by expressing
  commonality and variability
           explicitly.
All tests must pass       No code is duplicated




Code is self-explanatory   No superfluous parts exist
0   10   20   30   40   50   60   70   80
0   10   20   30   40   50   60   70   80
“The prime directive that was
unanimously agree upon by all
 present was that in the next
tens years Agile leaders must
Demand Technical Excellence.”

                Jeff Sutherland
“Failure to do that means
you are not an Agile leader.”


                Jeff Sutherland
Personal Action Plan
Reading
                                                                                        The Elements of Programming Style
                                                                                        Kernighan and Plauger


                                                                                        Prefactoring
                                                                                        Extreme Abstraction Extreme Separation Extreme Readability
                                                                                        Ken Pugh

          Pragmatic
            Programmers                       Agile in a Flash
                                                 Speed-Learning Agile
                                                Software Development
                                                                                        Agile in a Flash
                                                            Agile Cards for
                                                              Agile Teams               Speed-Learning Agile Development
                                                            Jeff Langr and
                                                              Tim Ottinger
                                                           edited by Susannah Pfalzer
                                                                                        Jeff Langr and Tim Ottinger
Prepared exclusively for Alistair McKinnell
Reading
Clean Code
A Handbook of Agile Software Craftsmanship
Robert C. Martin


Domain Driven Design
Tackling Complexity in the Heart of Software
Eric Evans


Implementation Patterns
Kent Beck
Reading
The Pragmatic Programmer: From Journeyman to Master
Andrew Hunt and Dave Thomas

Extreme Programming Explained: Embrace Change
Kent Beck and Cynthia Andres

Test Driven Development: By Example
Kent Beck

Object-Oriented Software Construction
Bertrand Meyer
Reading
Design Patterns: Elements of Reusable
Object-Oriented Software Erich Gamma,
Richard Helm, Ralph Johnson, and John Vlissides


Multi-Paradigm Design for C++
James O. Coplien



Lean Architecture: for Agile Software Development
James O. Coplien and Gertrud Bjørnvig
Photo Credits
http://www.flickr.com/photos/27558040@N00/4151899795/



http://www.flickr.com/photos/popilop/331357312/



http://www.flickr.com/photos/arlette/3260468/



http://www.flickr.com/photos/36829973@N04/3546657245/



http://www.flickr.com/photos/40838054@N00/7261734660/

Contenu connexe

Tendances

Breaking The Monotony
Breaking The MonotonyBreaking The Monotony
Breaking The MonotonyNaresh Jain
 
Schema Structures Qr 2
Schema Structures Qr 2Schema Structures Qr 2
Schema Structures Qr 2LiquidHub
 
C the complete_reference
C the complete_referenceC the complete_reference
C the complete_referencevinukondakiran
 
JavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisAriya Hidayat
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable codeGeshan Manandhar
 
In-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTMLIn-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTMLeSparkBiz
 
Embedding Languages Without Breaking Tools
Embedding Languages Without Breaking ToolsEmbedding Languages Without Breaking Tools
Embedding Languages Without Breaking ToolsLukas Renggli
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Railselliando dias
 
Condor overview - glideinWMS Training Jan 2012
Condor overview - glideinWMS Training Jan 2012Condor overview - glideinWMS Training Jan 2012
Condor overview - glideinWMS Training Jan 2012Igor Sfiligoi
 
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...Guillaume Laforge
 

Tendances (11)

Breaking The Monotony
Breaking The MonotonyBreaking The Monotony
Breaking The Monotony
 
Schema Structures Qr 2
Schema Structures Qr 2Schema Structures Qr 2
Schema Structures Qr 2
 
C the complete_reference
C the complete_referenceC the complete_reference
C the complete_reference
 
JavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality AnalysisJavaScript Parser Infrastructure for Code Quality Analysis
JavaScript Parser Infrastructure for Code Quality Analysis
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable code
 
Structured Query Language
Structured Query LanguageStructured Query Language
Structured Query Language
 
In-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTMLIn-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTML
 
Embedding Languages Without Breaking Tools
Embedding Languages Without Breaking ToolsEmbedding Languages Without Breaking Tools
Embedding Languages Without Breaking Tools
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Rails
 
Condor overview - glideinWMS Training Jan 2012
Condor overview - glideinWMS Training Jan 2012Condor overview - glideinWMS Training Jan 2012
Condor overview - glideinWMS Training Jan 2012
 
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
Groovy DSLs, from Beginner to Expert - Guillaume Laforge and Paul King - Spri...
 

En vedette

移动互联网上的微视频处理与分发
移动互联网上的微视频处理与分发移动互联网上的微视频处理与分发
移动互联网上的微视频处理与分发drewz lin
 
Distribute key value_store
Distribute key value_storeDistribute key value_store
Distribute key value_storedrewz lin
 
Solo iterative process
Solo iterative processSolo iterative process
Solo iterative processdrewz lin
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testabilitydrewz lin
 
Advocating For Action Presentation
Advocating For Action PresentationAdvocating For Action Presentation
Advocating For Action Presentationakeller4399
 
Testing systemqualities agile2012
Testing systemqualities   agile2012Testing systemqualities   agile2012
Testing systemqualities agile2012drewz lin
 
Douban qcon2009 beijing
Douban qcon2009 beijingDouban qcon2009 beijing
Douban qcon2009 beijingdrewz lin
 
Break down the silos collaboration techniques for teams 0
Break down the silos   collaboration techniques for teams 0Break down the silos   collaboration techniques for teams 0
Break down the silos collaboration techniques for teams 0drewz lin
 
Wetware craftsmanship
Wetware craftsmanshipWetware craftsmanship
Wetware craftsmanshipdrewz lin
 
Steve mushero china netcloud sz arch event 20120805.1
Steve mushero china netcloud sz arch event 20120805.1Steve mushero china netcloud sz arch event 20120805.1
Steve mushero china netcloud sz arch event 20120805.1drewz lin
 
Top100summit 当当网打造个性化推荐 精准营销生态系统傅强
Top100summit 当当网打造个性化推荐 精准营销生态系统傅强Top100summit 当当网打造个性化推荐 精准营销生态系统傅强
Top100summit 当当网打造个性化推荐 精准营销生态系统傅强drewz lin
 
刘源 人人网服务化与架构变迁V3
刘源 人人网服务化与架构变迁V3刘源 人人网服务化与架构变迁V3
刘源 人人网服务化与架构变迁V3drewz lin
 
敏捷测试中的工具实现
敏捷测试中的工具实现敏捷测试中的工具实现
敏捷测试中的工具实现drewz lin
 
Using rapid prototying_for_design_iteration
Using rapid prototying_for_design_iterationUsing rapid prototying_for_design_iteration
Using rapid prototying_for_design_iterationdrewz lin
 
Can marketing go agile
Can marketing go agileCan marketing go agile
Can marketing go agiledrewz lin
 
Net Ops Data Center Architecture Diagram 06
Net Ops Data Center Architecture Diagram 06Net Ops Data Center Architecture Diagram 06
Net Ops Data Center Architecture Diagram 06jeffqw
 

En vedette (16)

移动互联网上的微视频处理与分发
移动互联网上的微视频处理与分发移动互联网上的微视频处理与分发
移动互联网上的微视频处理与分发
 
Distribute key value_store
Distribute key value_storeDistribute key value_store
Distribute key value_store
 
Solo iterative process
Solo iterative processSolo iterative process
Solo iterative process
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability
 
Advocating For Action Presentation
Advocating For Action PresentationAdvocating For Action Presentation
Advocating For Action Presentation
 
Testing systemqualities agile2012
Testing systemqualities   agile2012Testing systemqualities   agile2012
Testing systemqualities agile2012
 
Douban qcon2009 beijing
Douban qcon2009 beijingDouban qcon2009 beijing
Douban qcon2009 beijing
 
Break down the silos collaboration techniques for teams 0
Break down the silos   collaboration techniques for teams 0Break down the silos   collaboration techniques for teams 0
Break down the silos collaboration techniques for teams 0
 
Wetware craftsmanship
Wetware craftsmanshipWetware craftsmanship
Wetware craftsmanship
 
Steve mushero china netcloud sz arch event 20120805.1
Steve mushero china netcloud sz arch event 20120805.1Steve mushero china netcloud sz arch event 20120805.1
Steve mushero china netcloud sz arch event 20120805.1
 
Top100summit 当当网打造个性化推荐 精准营销生态系统傅强
Top100summit 当当网打造个性化推荐 精准营销生态系统傅强Top100summit 当当网打造个性化推荐 精准营销生态系统傅强
Top100summit 当当网打造个性化推荐 精准营销生态系统傅强
 
刘源 人人网服务化与架构变迁V3
刘源 人人网服务化与架构变迁V3刘源 人人网服务化与架构变迁V3
刘源 人人网服务化与架构变迁V3
 
敏捷测试中的工具实现
敏捷测试中的工具实现敏捷测试中的工具实现
敏捷测试中的工具实现
 
Using rapid prototying_for_design_iteration
Using rapid prototying_for_design_iterationUsing rapid prototying_for_design_iteration
Using rapid prototying_for_design_iteration
 
Can marketing go agile
Can marketing go agileCan marketing go agile
Can marketing go agile
 
Net Ops Data Center Architecture Diagram 06
Net Ops Data Center Architecture Diagram 06Net Ops Data Center Architecture Diagram 06
Net Ops Data Center Architecture Diagram 06
 

Similaire à Simple design.published

Dynamic Language Performance
Dynamic Language PerformanceDynamic Language Performance
Dynamic Language PerformanceKevin Hazzard
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]Abhishek Sinha
 
Android classes-in-pune-syllabus
Android classes-in-pune-syllabusAndroid classes-in-pune-syllabus
Android classes-in-pune-syllabuscncandrwebworld
 
Android training in Nagpur
Android training in Nagpur Android training in Nagpur
Android training in Nagpur letsleadsand
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2Hammad Rajjoub
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2Hammad Rajjoub
 
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019Victor Rentea
 
Euro python 2015 writing quality code
Euro python 2015   writing quality codeEuro python 2015   writing quality code
Euro python 2015 writing quality coderadek_j
 
Refactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech Talk Refactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech Talk Ganesh Samarthyam
 
Refactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech TalkRefactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech TalkCodeOps Technologies LLP
 
Building Services With gRPC, Docker and Go
Building Services With gRPC, Docker and GoBuilding Services With gRPC, Docker and Go
Building Services With gRPC, Docker and GoMartin Kess
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and ToolsBob Paulin
 
Programming Design Guidelines
Programming Design GuidelinesProgramming Design Guidelines
Programming Design Guidelinesintuitiv.de
 

Similaire à Simple design.published (20)

Clean Code
Clean CodeClean Code
Clean Code
 
Dynamic Language Performance
Dynamic Language PerformanceDynamic Language Performance
Dynamic Language Performance
 
Icpc11b.ppt
Icpc11b.pptIcpc11b.ppt
Icpc11b.ppt
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
 
Clean code and code smells
Clean code and code smellsClean code and code smells
Clean code and code smells
 
Android classes-in-pune-syllabus
Android classes-in-pune-syllabusAndroid classes-in-pune-syllabus
Android classes-in-pune-syllabus
 
Android training in Nagpur
Android training in Nagpur Android training in Nagpur
Android training in Nagpur
 
Clean Code 2
Clean Code 2Clean Code 2
Clean Code 2
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019
 
Euro python 2015 writing quality code
Euro python 2015   writing quality codeEuro python 2015   writing quality code
Euro python 2015 writing quality code
 
Refactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech Talk Refactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech Talk
 
Refactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech TalkRefactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech Talk
 
Building Services With gRPC, Docker and Go
Building Services With gRPC, Docker and GoBuilding Services With gRPC, Docker and Go
Building Services With gRPC, Docker and Go
 
Headless Js Testing
Headless Js TestingHeadless Js Testing
Headless Js Testing
 
Clean code
Clean codeClean code
Clean code
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and Tools
 
BDD in my team: how we do it
BDD in my team: how we do itBDD in my team: how we do it
BDD in my team: how we do it
 
Programming Design Guidelines
Programming Design GuidelinesProgramming Design Guidelines
Programming Design Guidelines
 

Plus de drewz lin

Web security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-kearyWeb security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-kearydrewz lin
 
Via forensics appsecusa-nov-2013
Via forensics appsecusa-nov-2013Via forensics appsecusa-nov-2013
Via forensics appsecusa-nov-2013drewz lin
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13drewz lin
 
Owasp2013 johannesullrich
Owasp2013 johannesullrichOwasp2013 johannesullrich
Owasp2013 johannesullrichdrewz lin
 
Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2drewz lin
 
I mas appsecusa-nov13-v2
I mas appsecusa-nov13-v2I mas appsecusa-nov13-v2
I mas appsecusa-nov13-v2drewz lin
 
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfDefeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfdrewz lin
 
Csrf not-all-defenses-are-created-equal
Csrf not-all-defenses-are-created-equalCsrf not-all-defenses-are-created-equal
Csrf not-all-defenses-are-created-equaldrewz lin
 
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21drewz lin
 
Appsec usa roberthansen
Appsec usa roberthansenAppsec usa roberthansen
Appsec usa roberthansendrewz lin
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaoladrewz lin
 
Appsec2013 presentation-dickson final-with_all_final_edits
Appsec2013 presentation-dickson final-with_all_final_editsAppsec2013 presentation-dickson final-with_all_final_edits
Appsec2013 presentation-dickson final-with_all_final_editsdrewz lin
 
Appsec2013 presentation
Appsec2013 presentationAppsec2013 presentation
Appsec2013 presentationdrewz lin
 
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitationsAppsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitationsdrewz lin
 
Appsec2013 assurance tagging-robert martin
Appsec2013 assurance tagging-robert martinAppsec2013 assurance tagging-robert martin
Appsec2013 assurance tagging-robert martindrewz lin
 
Amol scadaowasp
Amol scadaowaspAmol scadaowasp
Amol scadaowaspdrewz lin
 
Agile sdlc-v1.1-owasp-app sec-usa
Agile sdlc-v1.1-owasp-app sec-usaAgile sdlc-v1.1-owasp-app sec-usa
Agile sdlc-v1.1-owasp-app sec-usadrewz lin
 
Vulnex app secusa2013
Vulnex app secusa2013Vulnex app secusa2013
Vulnex app secusa2013drewz lin
 
基于虚拟化技术的分布式软件测试框架
基于虚拟化技术的分布式软件测试框架基于虚拟化技术的分布式软件测试框架
基于虚拟化技术的分布式软件测试框架drewz lin
 
新浪微博稳定性经验谈
新浪微博稳定性经验谈新浪微博稳定性经验谈
新浪微博稳定性经验谈drewz lin
 

Plus de drewz lin (20)

Web security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-kearyWeb security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-keary
 
Via forensics appsecusa-nov-2013
Via forensics appsecusa-nov-2013Via forensics appsecusa-nov-2013
Via forensics appsecusa-nov-2013
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13
 
Owasp2013 johannesullrich
Owasp2013 johannesullrichOwasp2013 johannesullrich
Owasp2013 johannesullrich
 
Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2
 
I mas appsecusa-nov13-v2
I mas appsecusa-nov13-v2I mas appsecusa-nov13-v2
I mas appsecusa-nov13-v2
 
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfDefeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
 
Csrf not-all-defenses-are-created-equal
Csrf not-all-defenses-are-created-equalCsrf not-all-defenses-are-created-equal
Csrf not-all-defenses-are-created-equal
 
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
 
Appsec usa roberthansen
Appsec usa roberthansenAppsec usa roberthansen
Appsec usa roberthansen
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaola
 
Appsec2013 presentation-dickson final-with_all_final_edits
Appsec2013 presentation-dickson final-with_all_final_editsAppsec2013 presentation-dickson final-with_all_final_edits
Appsec2013 presentation-dickson final-with_all_final_edits
 
Appsec2013 presentation
Appsec2013 presentationAppsec2013 presentation
Appsec2013 presentation
 
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitationsAppsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
 
Appsec2013 assurance tagging-robert martin
Appsec2013 assurance tagging-robert martinAppsec2013 assurance tagging-robert martin
Appsec2013 assurance tagging-robert martin
 
Amol scadaowasp
Amol scadaowaspAmol scadaowasp
Amol scadaowasp
 
Agile sdlc-v1.1-owasp-app sec-usa
Agile sdlc-v1.1-owasp-app sec-usaAgile sdlc-v1.1-owasp-app sec-usa
Agile sdlc-v1.1-owasp-app sec-usa
 
Vulnex app secusa2013
Vulnex app secusa2013Vulnex app secusa2013
Vulnex app secusa2013
 
基于虚拟化技术的分布式软件测试框架
基于虚拟化技术的分布式软件测试框架基于虚拟化技术的分布式软件测试框架
基于虚拟化技术的分布式软件测试框架
 
新浪微博稳定性经验谈
新浪微博稳定性经验谈新浪微博稳定性经验谈
新浪微博稳定性经验谈
 

Simple design.published

  • 1. Simple Design Applied Spend more time creating valuable code Alistair McKinnell Declan Whelan @mckinnell @dwhelan
  • 3. What is Simple Design? On an index card write up to three facts on an index card. Be ready to share with your table.
  • 4. What is Simple Design? At your table gather the facts and count how many distinct facts you came up with.
  • 7.
  • 9. Simple Design At your table order the rules of simple design in priority order.
  • 10. Simple Design 1. All tests must pass 2. No code is duplicated 3. Code is self-explanatory 4. No superfluous parts exist
  • 11.
  • 12. Simple Design 1. All tests must pass 2. No code is duplicated 3. Code is self-explanatory 4. No superfluous parts exist
  • 13. Simple Design 1. Passes its tests 2. No code is duplicated 3. Code is self-explanatory 4. No superfluous parts exist
  • 14. Simple Design 1. Passes its tests 2. Minimizes duplication 3. Code is self-explanatory 4. No superfluous parts exist
  • 15. Simple Design 1. Passes its tests 2. Minimizes duplication 3. Maximizes clarity 4. No superfluous parts exist
  • 16. Simple Design 1. Passes its tests 2. Minimizes duplication 3. Maximizes clarity 4. Has fewer elements
  • 17. Simple Design 1. Passes its tests (given TDD) 2. Minimizes duplication 3. Maximizes clarity 4. Has fewer elements
  • 18. Simple Design 1. Passes its tests (given TDD) 2. Minimizes duplication 3. Maximizes clarity (fix names) 4. Has fewer elements
  • 19. Simple Design 1. Passes its tests (given TDD) 2. Minimizes duplication 3. Maximizes clarity (fix names) 4. Has fewer elements
  • 20. That leaves me with two key elements of simple design: remove duplication and fix bad names. When I remove duplication, I tend to see an appropriate structure emerge, and when I fix bad names, I tend to see responsibilities slide into appropriate parts of the design. J. B. Rainsberger
  • 21. Simple Design • Remove duplication • Fix bad names
  • 22. Simple Design (for today) • Fix bad names ❤ Choosing good names • Remove duplication ❤ Commonality & Variability
  • 24. Stroop Effect Green Red Blue Purple Blue Purple Green Red Blue Purple Blue Purple Blue Purple Red Green Purple Green
  • 25. Meaning: Colour: black yellow
  • 26. Meaning: Colour: blue black
  • 44. CComBstr sVal $.getJSON() int result Rx rx applyMeasureConstraintToEnableSortingByMeasure() float hp applyPhq9DateRangeConstraint() public void run() Date genymdhms m_name Label label IShapeFactory Customer int i RollOverPerformanceIndicatorsToNextMonthTask CustomerManager LPSTR lpCmdLine int daysSinceModification boolean fNewPage UpdatePerfIndValueDecCountCmd DepressionSelfManagementCalculator Tutorial02 PerfIndValueDecCountForMatchingIvpCmd PulseRenderer IndexCardPageLayout sut
  • 45. CComBstr sVal $.getJSON() int result Rx rx applyMeasureConstraintToEnableSortingByMeasure() float hp applyPhq9DateRangeConstraint() public void run() Date genymdhms m_name Label label IShapeFactory Customer int i RollOverPerformanceIndicatorsToNextMonthTask CustomerManager LPSTR lpCmdLine int daysSinceModification boolean fNewPage UpdatePerfIndValueDecCountCmd DepressionSelfManagementCalculator Tutorial02 PerfIndValueDecCountForMatchingIvpCmd PulseRenderer IndexCardPageLayout sut
  • 46. Find a partner and each of you: 1. select a name you thought was good 2. explain why to your partner 3. select a name you thought was bad 4. explain why to your partner CComBstr sVal $.getJSON() int result Rx rx applyMeasureConstraintToEnableSortingByMeasure() float hp applyPhq9DateRangeConstraint() public void run() Date genymdhms m_name Label label IShapeFactory Customer int i RollOverPerformanceIndicatorsToNextMonthTask CustomerManager LPSTR lpCmdLine int daysSinceModification boolean fNewPage UpdatePerfIndValueDecCountCmd DepressionSelfManagementCalculator PerfIndValueDecCountForMatchingIvpCmd PulseRenderer IndexCardPageLayout sut
  • 48. Choosing Good Names Use the telephone test for readability. If someone could understand your code when read aloud over the telephone, it's clear enough. If not, then it needs rewriting.
  • 49. Telephone Test Goal Donor vs Gold Owner Date genymdhms
  • 50. Choosing Good Names Splitters can be lumped more easily than lumpers can be split. It is easier to combine two concepts that it is to separate them.
  • 51. Splitting a Lumper Customer Address
  • 52. Splitting a Lumper Customer Address Billing Address Mailing Address Service Address
  • 53. Lumping a Splitter Billing Address Mailing Address Service Address
  • 54. Lumping a Splitter Billing Address Mailing Address Service Address Customer Address
  • 55. Choosing Good Names Pronounceable Names Avoid Encodings
  • 60. Avoid Encodings LPSTR lpCmdLine LPSTR commandLine m_name name
  • 61. Choosing Good Names Intention-Revealing Name Role-Suggesting Name
  • 63. Intention-Revealing Name applyMeasureConstraintTo EnableSortingByMeasure() applyMeasureConstraint()
  • 65. Choosing Good Names Ubiquitous Language
  • 70. Ubiquitous Language applyPhq9DateRangeConstraint() The PHQ-9 is the nine item depression scale of the Patient Health Questionnaire. The PHQ-9 is a powerful tool for assisting primary care clinicians in diagnosing depression as well as selecting and monitoring treatment.
  • 71. Pragmatic Programmers Agile in a Flash Speed-Learning Agile Software Development Agile Cards for Agile Teams Jeff Langr and Tim Ottinger edited by Susannah Pfalzer Prepared exclusively for Alistair McKinnell Copyright ©2011 Pragmatic Programmers
  • 72. 43 Really Meaningful Names ® Are accurate ® Are purposeful ® Are pronounceable ® Begin well ® Are simple ® Depend on context ® Match name length to scope Prepared exclusively for Alistair McKinnell Copyright ©2011 Pragmatic Programmers
  • 73. Choosing Good Names •Locate one Naming'Guidelines System'of'Names S1# # Name#pass#the#“telephone”#test. S2# # There#is#a#clean#name#for#each#concept.#Remember:#later#on#it’s#easier#to#lump# guideline that if things#together#than#to#split#them#apart. S3# # Name#is#from#the#problem#or#solu?on#domain#and#support#ubiquitous#language#for# the#team General applied would have G1## Name#is#pronounceable. G2## Name#avoids#encodings#and#member#prefixes. G3## Name#suggest#why#it#exists. G4## Name#suggest#how#it#should#be#used. the biggest impact G5## Name#suggest#what#it#does. G6## Name#is#easily#searchable#in#the#code#base. Classes C1# If#this#is#an#important#base#class#its#class#name#should#be#a#simple#single#word. C2# C3# If#this#is#a#subclass#its#class#name#suggests#how#it#differs#from#its#superclass. The#class#name#is#a#noun#or#a#noun#phrase. on your code •Find a partner Methods M1# The#method#name#suggests#why#it#would#be#called. M2# The#method#is#name#a#verb#or#a#verb#phrase. Variables/Fields/Arguments •Discuss V1# Its#name#indicate#the#role#it's#playing. V2# The#length#of#the#name#reflect#its#scope. Alistair McKinnell @amckinnell Declan Whelan @dwhelan Naming Guidelines v1.0 August 2012 ! 1/1
  • 74. Choosing Good Names public List<int[]> getThem() { List<int[]> list1 = new ArrayList<int[]>(); for (int[] x : theList) if (x[0] == 4) list1.add(x); return list1; } Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, pages 18-19
  • 75. Choosing Good Names public List<int[]> getThem() { List<int[]> list1 = new ArrayList<int[]>(); for (int[] x : theList) if (x[0] == 4) list1.add(x); return list1; } public List<int[]> getFlaggedCells() { List<int[]> flaggedCells = new ArrayList<int[]>(); for (int[] cell : gameBoard) if (cell[STATUS_VALUE] == FLAGGED) flaggedCells.add(cell); return flaggedCells; } Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, pages 18-19
  • 76. Choosing Good Names public List<int[]> getThem() { List<int[]> list1 = new ArrayList<int[]>(); for (int[] x : theList) if (x[0] == 4) list1.add(x); return list1; } public List<Cell> getFlaggedCells() { List<Cell> flaggedCells = new ArrayList<Cell>(); for (Cell cell : gameBoard) if (cell.isFlagged()) flaggedCells.add(cell); return flaggedCells; } Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, pages 18-19
  • 77. Choosing Good Names public List<int[]> getThem() { List<int[]> list1 = new ArrayList<int[]>(); for (int[] x : theList) if (x[0] == 4) list1.add(x); return list1; } public List<Cell> getFlaggedCells() { List<Cell> result = new ArrayList<Cell>(); for (Cell cell : gameBoard) if (cell.isFlagged()) result.add(cell); return result; } Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, pages 18-19
  • 78. Choosing Good Names int s = 0; for (int j=0; j<34; j++) { s += (t[j]*4)/5; } const int EFFECTIVE_DAYS_PER_WEEK = 4; int realDaysPerIdealDay = 4; const int WORKING_DAYS_PER_WEEK = 5; const int WORK_DAYS_PER_WEEK = 5; int sum = 0; int effectiveTotalEstimate = 0; for (int j=0; j < NUMBER_OF_TASKS; j++) { for (int j=0; j < NUMBER_OF_TASKS; j++) {realDaysPerIdealDay; int realTaskDays = taskEstimate[j] * int effectiveTaskEstimate = int realTaskWeeks = (realdays / WORK_DAYS_PER_WEEK); taskEstimate[j] * EFFECTIVE_DAYS_PER_WEEK / WORKING_DAYS_PER_WEEK; sum += realTaskWeeks; effectiveTotalEstimate += effectiveTaskEstimate; } } Source: Clean Code: A Handbook of Agile Software Craftsmanship, Robert C. Martin, page 23
  • 79. What’s In A Name? Moonbeam Zappa
  • 80.
  • 81. All tests must pass No code is duplicated Code is self-explanatory No superfluous parts exist
  • 82. No code is duplicated
  • 84. How do you handle duplicate code in your codebase?
  • 85.
  • 86. Avoiding Duplicate Code DRY: Don’t Repeat Yourself Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
  • 87. Avoiding Duplicate Code Once and Only Once Data, structure, or logic should exist in only one place in the system.
  • 88. Avoiding Duplicate Code Test-Driven Development 1. Write new code only if an automated test has failed. 2. Eliminate duplication.
  • 89. Avoiding Duplicate Code Single Choice Principle Whenever a software system must support a set of alternatives, one and only one module in the system should know their exhaustive list.
  • 90. Avoiding Duplicate Code Duplication may be the root of all evil in software.
  • 91.
  • 96. function something() { } function somethingElse() { }
  • 97. function something() { } function somethingElse() { }
  • 98. Duplicate Code Copy & Paste Edit the Copy ☞ Duplicate Code
  • 99. Duplicate Code Avoid duplication by expressing commonality and variability explicitly.
  • 100. function something() { } function somethingElse() { }
  • 102. Can you spot the commonality and variation? Can you spot the duplicate code? How would you make the commonality and variation explicit?
  • 103.
  • 104. public static List<SelectOption> createEndMonthList(Date expiryDate) { int selectedMonth = getDateMonth(expiryDate); SelectOptionsSource months = new SelectOptionsSource(1, 12, selectedMonth); SelectOptions monthOptions = new SelectOptions(months); return monthOptions.create(); } public static List<SelectOption> createEndDaysList() { int selectedDay = getDateDay(getCurrentDatePlus14Days()); SelectOptionsSource days = new SelectOptionsSource(1, 31, selectedDay); SelectOptions dayOptions = new SelectOptions(days); return dayOptions.create(); } public static List<SelectOption> createEndYearList() { int selectedYear = getDateYear(getCurrentDatePlus14Days()); SelectOptionsSource years = new SelectOptionsSource(1985, 1985 + 30, selectedYear); SelectOptions yearOptions = new SelectOptions(years); return yearOptions.create(); }
  • 105. public static List<SelectOption> createEndMonthList(Date expiryDate) { int selectedMonth = getDateMonth(expiryDate); SelectOptionsSource months = new SelectOptionsSource(1, 12, selectedMonth); SelectOptions monthOptions = new SelectOptions(months); return monthOptions.create(); } public static List<SelectOption> createEndDaysList() { int selectedDay = getDateDay(getCurrentDatePlus14Days()); SelectOptionsSource days = new SelectOptionsSource(1, 31, selectedDay); SelectOptions dayOptions = new SelectOptions(days); return dayOptions.create(); } public static List<SelectOption> createEndYearList() { int selectedYear = getDateYear(getCurrentDatePlus14Days()); SelectOptionsSource years = new SelectOptionsSource(1985, 1985 + 30, selectedYear); SelectOptions yearOptions = new SelectOptions(years); return yearOptions.create(); }
  • 106. public static List<SelectOption> createEndMonthList(Date expiryDate) { int selectedMonth = getDateMonth(expiryDate); SelectOptionsSource months = new SelectOptionsSource(1, 12, selectedMonth); SelectOptions monthOptions = new SelectOptions(months); return monthOptions.create(); } public static List<SelectOption> createEndDaysList() { int selectedDay = getDateDay(getCurrentDatePlus14Days()); SelectOptionsSource days = new SelectOptionsSource(1, 31, selectedDay); SelectOptions dayOptions = new SelectOptions(days); return dayOptions.create(); } public static List<SelectOption> createEndYearList() { int selectedYear = getDateYear(getCurrentDatePlus14Days()); SelectOptionsSource years = new SelectOptionsSource(1985, 1985 + 30, selectedYear); SelectOptions yearOptions = new SelectOptions(years); return yearOptions.create(); }
  • 107. Select Options SelectOptions SelectOptionsSource create() getFirst() getLast() isSelected() Commonality Variability Resolution Encapsulate Behaviour Collaborator Collection
  • 108. Select Options SelectOptions SelectOptionsSource create() getFirst() getLast() isSelected() Commonality Variability Resolution Data Structure Value of State Simple Java Type
  • 109.
  • 110. Select Options SelectOptions SelectOptionsSource create() getFirst() getLast() isSelected() Encapsulate Collection
  • 111. Select Options SelectOptions SelectOptionsSource create() getFirst() getLast() isSelected() Parameter Object
  • 113. Can you spot the commonality and variation? Can you spot the duplicate code? How would you make the commonality and variation explicit?
  • 114. if ( ... ) { } else { }
  • 115. Compound Result Handler CompoundResultHandler CompoundResultClassifier isNegative() isPositive() AbstractCompoundResultClassifier toNumber() QueensCompoundResultClassifier StandardCompoundResultClassifier isNegative() isNegative() isPositive() isPositive()
  • 116. Compound Result Handler CompoundResultHandler CompoundResultClassifier isNegative() isPositive() AbstractCompoundResultClassifier toNumber() QueensCompoundResultClassifier StandardCompoundResultClassifier isNegative() isNegative() isPositive() isPositive()
  • 117. Compound Result Handler CompoundResultHandler CompoundResultClassifier isNegative() isPositive() AbstractCompoundResultClassifier toNumber() QueensCompoundResultClassifier StandardCompoundResultClassifier isNegative() isNegative() isPositive() isPositive() Commonality Variability Resolution Inheritance Behaviour Implementation (Object-Oriented)
  • 118. Compound Result Handler CompoundResultHandler CompoundResultClassifier isNegative() isPositive() AbstractCompoundResultClassifier toNumber() QueensCompoundResultClassifier StandardCompoundResultClassifier isNegative() isNegative() isPositive() isPositive() Commonality Variability Resolution Inheritance Behaviour Implementation (Object-Oriented)
  • 119. Compound Result Handler CompoundResultHandler CompoundResultClassifier isNegative() isPositive() AbstractCompoundResultClassifier toNumber() QueensCompoundResultClassifier StandardCompoundResultClassifier isNegative() isNegative() isPositive() isPositive() Commonality Variability Resolution Implementation None Base Class
  • 120. Compound Result Handler CompoundResultHandler CompoundResultClassifier isNegative() isPositive() AbstractCompoundResultClassifier toNumber() QueensCompoundResultClassifier StandardCompoundResultClassifier isNegative() isNegative() isPositive() isPositive() Commonality Variability Resolution Implementation None Base Class
  • 121. Compound Result Handler public static CompoundResultClassifier createCompoundResultClassifier( Patient sourcePatient) { return isRegisteredAtQueens(sourcePatient) ? QUEENS : STANDARD; } private static boolean isRegisteredAtQueens(Patient sourcePatient) { return sourcePatient.getDataWarehouse().equals(DataWarehouseTag.QHN); } Factory
  • 122.
  • 125. Duplicate Code Copy & Paste Edit the Copy ☞ Duplicate Code
  • 126. Duplicate Code Avoid duplication by expressing commonality and variability explicitly.
  • 127.
  • 128. All tests must pass No code is duplicated Code is self-explanatory No superfluous parts exist
  • 129. 0 10 20 30 40 50 60 70 80
  • 130. 0 10 20 30 40 50 60 70 80
  • 131. “The prime directive that was unanimously agree upon by all present was that in the next tens years Agile leaders must Demand Technical Excellence.” Jeff Sutherland
  • 132. “Failure to do that means you are not an Agile leader.” Jeff Sutherland
  • 134. Reading The Elements of Programming Style Kernighan and Plauger Prefactoring Extreme Abstraction Extreme Separation Extreme Readability Ken Pugh Pragmatic Programmers Agile in a Flash Speed-Learning Agile Software Development Agile in a Flash Agile Cards for Agile Teams Speed-Learning Agile Development Jeff Langr and Tim Ottinger edited by Susannah Pfalzer Jeff Langr and Tim Ottinger Prepared exclusively for Alistair McKinnell
  • 135. Reading Clean Code A Handbook of Agile Software Craftsmanship Robert C. Martin Domain Driven Design Tackling Complexity in the Heart of Software Eric Evans Implementation Patterns Kent Beck
  • 136. Reading The Pragmatic Programmer: From Journeyman to Master Andrew Hunt and Dave Thomas Extreme Programming Explained: Embrace Change Kent Beck and Cynthia Andres Test Driven Development: By Example Kent Beck Object-Oriented Software Construction Bertrand Meyer
  • 137. Reading Design Patterns: Elements of Reusable Object-Oriented Software Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides Multi-Paradigm Design for C++ James O. Coplien Lean Architecture: for Agile Software Development James O. Coplien and Gertrud Bjørnvig