The Technical Debt of the Programming Languages … and the influence in our designs Hernán Wilkinson – Jorge Silva Agile 2011
Fuente: http://c2.com/cgi/wiki?WardExplainsDebtMetaphor Technical Deb Metaphor… Debt Speed Burden Agility … if we failed t...
 
<ul><li>Language implies Thinking </li></ul>
<ul><li>Language implies Thinking </li></ul>Thinking implies Language
<ul><li>What we can not talk about… </li></ul><ul><li>we can not think about </li></ul>
<ul><li>Let’s think about this problem: </li></ul>How do we call the whole thing?
<ul><li>Let’s say Traffic Light (Semáforo) </li></ul>How do we call each part?
<ul><li>Let’s say Traffic Controller </li></ul>How do we call each Traffic Controller in the Traffic Light?
aTrafficLight northSouthController eastWestController
aTrafficLight rightController leftController
aTrafficLight controller1 controller2
<ul><li>Not easy way to name them… </li></ul><ul><li>Relative vs. Fix Coordinate System </li></ul>B. Lee Whorf (Linguistic...
<ul><li>What is the relationship with Programming Languages? </li></ul>
<ul><li>If a programming language does not allow me to “TALK” (write) about certain things </li></ul><ul><li>… </li></ul><...
<ul><li>ABSTRACTION </li></ul>
<ul><li>How do we refer to that “thing that has four wheels and moves?” </li></ul>
<ul><li>and to “that thing that moves and has four wheels?” </li></ul>
<ul><li>and to “that one the moves because it has four wheels?” </li></ul>
To avoid REPETITION To provide MEANING to that REPETITION
<ul><li>If we have repetition we are lacking and abstraction… (an object in OO) </li></ul>Meta Note: I repeated the pictur...
<ul><li>Let’s see </li></ul>List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: custome...
<ul><li>We have repeated code! </li></ul>List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer cust...
<ul><li>“ Repeated code” does not mean “repeated text”. </li></ul><ul><li>It means “repeated patterns of collaboration” </...
<ul><li>What is the problem? </li></ul>
<ul><li>We are lacking an ABSTRACTION! </li></ul>Repeated code means we are forgetting an object!
<ul><li>How do we remove it? </li></ul>
<ul><li>Technique: </li></ul><ul><li>Copy the repeated code to some “place” </li></ul><ul><li>Parameterize what changes </...
<ul><li>Copy the repeated code to some place </li></ul>List<Customer> selectedCustomers = new ArrayList<Customer> (); for ...
<ul><li>Parameterize what changes </li></ul>List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer c...
<ul><li>How do we do it? </li></ul>
<ul><li>We need an abstraction to represent “code” </li></ul>We need a BLOCK or a CLOSURE… …  an object that represents “c...
<ul><li>Parameterize what changes </li></ul>class Collection<T> { public  Collection<T> <<NAME>> (Closure aClosure) { List...
<ul><li>NAME IT!! </li></ul>class Collection<T> { public  Collection<T> select (Closure aClosure) { List<T> selected = new...
List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if (customer.nameStarsWi...
customers.select( new SelectClosure<Customer> () { public boolean value (Customer aCustomer) { return aCustomer.nameStarts...
<ul><li>What did we gain? </li></ul><ul><li>Few words    Simplicity, Easier to understand, read, remember, etc. Less bugs...
<ul><li>Now… let’s do some reflection </li></ul><ul><li>Why didn’t we see the “duplicated code”? </li></ul><ul><li>Why did...
<ul><li>Why didn’t we see the “duplicated code” </li></ul><ul><li>Because we are use to that code (is the programming lang...
<ul><li>Why didn’t we came with a solution? </li></ul><ul><li>Because the programming language does not provide us with a ...
cutomers reject: [ :aCustomer | aCustomer nameStartsWith: ‘H’ ] (Smalltalk) customers.reject { | aCustomer | aCustomer.nam...
List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if (customer.nameStarsWi...
customers collect: [ :aCustomer | aCustomer name ]  (Smalltalk) customers.collect { | aCustomer | aCustomer.name () }  (Ru...
self  should: [ do something ] raise: Exception withExceptionDo: [ :e | self assert: …. ]  (Smallalk) C# Does not have one...
<ul><li>Further reading: LAMBDA The Ultimate… </li></ul>… and much much more…. Imagine how your designs would be if you co...
<ul><li>How do we learn a new word? </li></ul>
<ul><li>Do we: </li></ul><ul><li>Stop our brain </li></ul><ul><li>“ edit&quot; a new definition in our dictionary </li></u...
<ul><li>NO!! </li></ul>Why do we have to do it with our programs?
<ul><li>Can our programs “change while running”? </li></ul><ul><li>Can our programs “learn” as we learn? </li></ul>
<ul><li>Yes, they can!... If they are </li></ul><ul><li>METACIRCULAR </li></ul>Apply Eval
<ul><li>Let’s see a problem: </li></ul><ul><li>Can you make a proxy “learn” about its proxee as it is used? </li></ul>
<ul><li>If we don’t have meta-circular languages, then we can not think about solutions where meta-programming would fit! ...
<ul><li>Let’s think again… </li></ul>Are these concepts new?
<ul><li>Lisp </li></ul>John McCarthy Alan Kay “ We must know our history if we don’t want to reinvent …  not only the tire...
<ul><li>Why not having closures generate debt? </li></ul><ul><li>Repeated code </li></ul><ul><li>Lack of abstractions </li...
<ul><li>Why not having meta-programming generate debt? </li></ul><ul><li>Some problems are more difficult to solve    Mor...
Technical Deb Quadrant Fuente: http://martinfowler.com/bliki/TechnicalDebtQuadrant.html
<ul><li>Conclusions </li></ul><ul><li>Do not accept languages without Closures </li></ul><ul><li>Do not accept languages w...
<ul><li>We teach this and other important design aspects in our courses </li></ul><ul><li>Advance Design with OO : Nov 14 ...
Questions?
<ul><li>Muchas gracias! </li></ul>[email_address] www.10Pines.com twitter: @10Pines Argentina Tel.:  +54 (11) 4780-2460 Av...
Upcoming SlideShare
Loading in...5
×

The Technical Debt of Programming Languages

7,167

Published on

Talk given at Agiles 2011, Argentina

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,167
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

The Technical Debt of Programming Languages

  1. 1. The Technical Debt of the Programming Languages … and the influence in our designs Hernán Wilkinson – Jorge Silva Agile 2011
  2. 2. Fuente: http://c2.com/cgi/wiki?WardExplainsDebtMetaphor Technical Deb Metaphor… Debt Speed Burden Agility … if we failed to make our program align with what we then understood  … write code that is clean enough to be able to refactor as you come to understand your problem With borrowed money you can do something sooner than you might   put that learning back into the program
  3. 4. <ul><li>Language implies Thinking </li></ul>
  4. 5. <ul><li>Language implies Thinking </li></ul>Thinking implies Language
  5. 6. <ul><li>What we can not talk about… </li></ul><ul><li>we can not think about </li></ul>
  6. 7. <ul><li>Let’s think about this problem: </li></ul>How do we call the whole thing?
  7. 8. <ul><li>Let’s say Traffic Light (Semáforo) </li></ul>How do we call each part?
  8. 9. <ul><li>Let’s say Traffic Controller </li></ul>How do we call each Traffic Controller in the Traffic Light?
  9. 10. aTrafficLight northSouthController eastWestController
  10. 11. aTrafficLight rightController leftController
  11. 12. aTrafficLight controller1 controller2
  12. 13. <ul><li>Not easy way to name them… </li></ul><ul><li>Relative vs. Fix Coordinate System </li></ul>B. Lee Whorf (Linguistic Relativity)
  13. 14. <ul><li>What is the relationship with Programming Languages? </li></ul>
  14. 15. <ul><li>If a programming language does not allow me to “TALK” (write) about certain things </li></ul><ul><li>… </li></ul><ul><li>Then I can not THINK about certain solutions </li></ul>
  15. 16. <ul><li>ABSTRACTION </li></ul>
  16. 17. <ul><li>How do we refer to that “thing that has four wheels and moves?” </li></ul>
  17. 18. <ul><li>and to “that thing that moves and has four wheels?” </li></ul>
  18. 19. <ul><li>and to “that one the moves because it has four wheels?” </li></ul>
  19. 20. To avoid REPETITION To provide MEANING to that REPETITION
  20. 21. <ul><li>If we have repetition we are lacking and abstraction… (an object in OO) </li></ul>Meta Note: I repeated the picture… I’m lacking an abstraction or a better image! 
  21. 22. <ul><li>Let’s see </li></ul>List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if (customer.nameStarsWith(“H”)) selectedCustomers.add (customer); return selectedCustomers; List<Account> selectedAccounts = new ArrayList<Account> (); for (Account account: accounts) if (account.isOverdraw()) selectedAccounts.add(account); return selectedAccount; What is the problem?
  22. 23. <ul><li>We have repeated code! </li></ul>List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if ( customer.nameStarsWith(“H”) ) selectedCustomers.add (customer); return selectedCustomers; List<Account> selectedAccounts = new ArrayList<Account> (); for (Account account: accounts) if ( account.isOverdraw() ) selectedAccounts.add(account); return selectedAccount;
  23. 24. <ul><li>“ Repeated code” does not mean “repeated text”. </li></ul><ul><li>It means “repeated patterns of collaboration” </li></ul>
  24. 25. <ul><li>What is the problem? </li></ul>
  25. 26. <ul><li>We are lacking an ABSTRACTION! </li></ul>Repeated code means we are forgetting an object!
  26. 27. <ul><li>How do we remove it? </li></ul>
  27. 28. <ul><li>Technique: </li></ul><ul><li>Copy the repeated code to some “place” </li></ul><ul><li>Parameterize what changes </li></ul><ul><li>NAME IT!!! </li></ul>
  28. 29. <ul><li>Copy the repeated code to some place </li></ul>List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if ( customer.nameStarsWith(“H”) ) selectedCustomers.add(customer); return selectedCustomers; List<Account> selectedAccounts = new ArrayList<Account> (); for (Account account: accounts) if ( account.isOverdraw() ) selectedAccounts.add(account); return selectedAccount; class Collection<T> { public Collection<T> <<NAME>> { List<T> selected = new ArrayList<T> (); for (T anObject: this) if ( ) selected.add (anObject); return selected: }
  29. 30. <ul><li>Parameterize what changes </li></ul>List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if ( customer.nameStarsWith(“H”) ) selectedCustomers.add (customer); return selectedCustomers; List<Account> selectedAccounts = new ArrayList<Account> (); for (Account account: accounts) if ( account.isOverdraw() ) selectedAccounts.add(account); return selectedAccount; How do we do it?
  30. 31. <ul><li>How do we do it? </li></ul>
  31. 32. <ul><li>We need an abstraction to represent “code” </li></ul>We need a BLOCK or a CLOSURE… … an object that represents “code”
  32. 33. <ul><li>Parameterize what changes </li></ul>class Collection<T> { public Collection<T> <<NAME>> (Closure aClosure) { List<T> selected = new ArrayList<T> (); for (T anObject: this) if ( aClosure.value(anObject) ) selected.add (anObject); return selected:} List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if ( customer.nameStarsWith(“H”) ) selectedCustomers.add(customer); return selectedCustomers; List<Account> selectedAccounts = new ArrayList<Account> (); for (Account account: accounts) if ( account.isOverdraw() ) selectedAccounts.add(account); return selectedAccount;
  33. 34. <ul><li>NAME IT!! </li></ul>class Collection<T> { public Collection<T> select (Closure aClosure) { List<T> selected = new ArrayList<T> (); for (T anObject: this) if ( aClosure.value(anObject ) ) selected.add (anObject); return selected:} The most difficult part because it means that we understood the repeated code meaning List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if ( customer.nameStarsWith(“H”) ) selectedCustomers.add(customer); return selectedCustomers; List<Account> selectedAccounts = new ArrayList<Account> (); for (Account account: accounts) if ( account.isOverdraw() ) selectedAccounts.add(account); return selectedAccount;
  34. 35. List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if (customer.nameStarsWith(“H”)) selectedCustomers.add (customer); return selectedCustomers; List<Account> selectedAccounts = new ArrayList<Account> (); for (Account account: accounts) if (account.isOverdraw()) selectedAccounts.add(account); return selectedAccount; cutomers.select( customer => customer.nameStartsWith(“H”) ) accounts.select( account => account.isOverdraw() )
  35. 36. customers.select( new SelectClosure<Customer> () { public boolean value (Customer aCustomer) { return aCustomer.nameStartsWith(“H”); }}); cutomers.select( customer => customber.nameStartsWith(“H”) ) <ul><li>Why not an Anonymous Class? </li></ul><ul><li>Sintax: </li></ul><ul><li>Which one reads better? </li></ul><ul><li>Binding problems… </li></ul>
  36. 37. <ul><li>What did we gain? </li></ul><ul><li>Few words  Simplicity, Easier to understand, read, remember, etc. Less bugs! </li></ul><ul><li>We created a new “abstraction”: select </li></ul><ul><li>… and we remove duplicated code!! </li></ul>
  37. 38. <ul><li>Now… let’s do some reflection </li></ul><ul><li>Why didn’t we see the “duplicated code”? </li></ul><ul><li>Why didn’t we came with a solution? </li></ul>
  38. 39. <ul><li>Why didn’t we see the “duplicated code” </li></ul><ul><li>Because we are use to that code (is the programming language the problem or us?) </li></ul><ul><li>Because there is no “tool” to remove it </li></ul>
  39. 40. <ul><li>Why didn’t we came with a solution? </li></ul><ul><li>Because the programming language does not provide us with a “tool” to solve it! </li></ul><ul><li>DOES NOT REALLY? </li></ul>
  40. 41. cutomers reject: [ :aCustomer | aCustomer nameStartsWith: ‘H’ ] (Smalltalk) customers.reject { | aCustomer | aCustomer.nameStartsWith(“H”) } (Ruby) customers.Where( aCustomer => !aCustomer.nameStarsWith(“H”)) (C#) reject List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if (!customer.nameStarsWith(“H”)) selectedCustomers.add (customer); return selectedCustomers;
  41. 42. List<Customer> selectedCustomers = new ArrayList<Customer> (); for (Customer customer: customers) if (customer.nameStarsWith(“H”)) return customer; throw …. customers detect: [ :aCustomer | aCustomer nameStartsWith: ‘H’ ](Smalltalk) customers.detect { | aCustomer | aCustomer.nameStartsWith(“H”) } (Ruby) customers.First ( aCustomer => aCustomer.nameStarstWith(“H”)) (C#) detect
  42. 43. customers collect: [ :aCustomer | aCustomer name ] (Smalltalk) customers.collect { | aCustomer | aCustomer.name () } (Ruby) customers.Select( aCustomer => aCustomer.name() ) (C#) collect List<String> customerNames = new ArrayList<String> (); for (Customer customer: customers) customerNames.add (customer.name()); return customerNames;
  43. 44. self should: [ do something ] raise: Exception withExceptionDo: [ :e | self assert: …. ] (Smallalk) C# Does not have one that I’m aware of … TDD: Test for exceptions Try { … do something fail() } catch (Exception e) { assertTrue (…. ) }
  44. 45. <ul><li>Further reading: LAMBDA The Ultimate… </li></ul>… and much much more…. Imagine how your designs would be if you could use closures
  45. 46. <ul><li>How do we learn a new word? </li></ul>
  46. 47. <ul><li>Do we: </li></ul><ul><li>Stop our brain </li></ul><ul><li>“ edit&quot; a new definition in our dictionary </li></ul><ul><li>“ Compile” the new definition </li></ul><ul><li>Restart our brain? </li></ul>
  47. 48. <ul><li>NO!! </li></ul>Why do we have to do it with our programs?
  48. 49. <ul><li>Can our programs “change while running”? </li></ul><ul><li>Can our programs “learn” as we learn? </li></ul>
  49. 50. <ul><li>Yes, they can!... If they are </li></ul><ul><li>METACIRCULAR </li></ul>Apply Eval
  50. 51. <ul><li>Let’s see a problem: </li></ul><ul><li>Can you make a proxy “learn” about its proxee as it is used? </li></ul>
  51. 52. <ul><li>If we don’t have meta-circular languages, then we can not think about solutions where meta-programming would fit! </li></ul>
  52. 53. <ul><li>Let’s think again… </li></ul>Are these concepts new?
  53. 54. <ul><li>Lisp </li></ul>John McCarthy Alan Kay “ We must know our history if we don’t want to reinvent … not only the tire, but a a flat tire”
  54. 55. <ul><li>Why not having closures generate debt? </li></ul><ul><li>Repeated code </li></ul><ul><li>Lack of abstractions </li></ul><ul><li>Difficult and costly to maintain </li></ul>
  55. 56. <ul><li>Why not having meta-programming generate debt? </li></ul><ul><li>Some problems are more difficult to solve  More code! </li></ul><ul><li>Programs can not reason about programs or themselves </li></ul><ul><li>We always need a programmer to do something a program could do </li></ul>
  56. 57. Technical Deb Quadrant Fuente: http://martinfowler.com/bliki/TechnicalDebtQuadrant.html
  57. 58. <ul><li>Conclusions </li></ul><ul><li>Do not accept languages without Closures </li></ul><ul><li>Do not accept languages without meta-programming </li></ul><ul><li>… “ it is not about language maturity but about programmers maturity” (Máximo Prieto) </li></ul>
  58. 59. <ul><li>We teach this and other important design aspects in our courses </li></ul><ul><li>Advance Design with OO : Nov 14 th </li></ul><ul><li>TDD : Oct 25 th , Nov 22 nd </li></ul><ul><li>Check them out at: </li></ul><ul><li>http://www.10pines.com/content/cursosdisponibles </li></ul>
  59. 60. Questions?
  60. 61. <ul><li>Muchas gracias! </li></ul>[email_address] www.10Pines.com twitter: @10Pines Argentina Tel.: +54 (11) 4780-2460 Av. Monroe 2164 (1428) Buenos Aires

×