SlideShare une entreprise Scribd logo
1  sur  67
JavaScript is Real Code


                              Len Smith
                                  @ignu
                           http://iggy.nu
                    len.smith@live.com
Document
 Object
 Model
“JavaScript is the only language
 I’m aware of where people feel
they don’t have to learn it before
       they start using it”
           -Douglas Crockford
Dynamic
Loose Typing
number
         boolean
                   string
                            undefined
                                       object
                                        Regex

                                        Date

                                        Array
“Lisp in C’s clothing”
function() {}
SOLID?
Single Responsibility Principle
Open Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
JavaScript
    Isn’t
Shouldn’t be
    OO
Rules of Simple Design
Rules of Simple Design
 •   Passes Tests
Rules of Simple Design
 •Passes Tests
 • Removes Duplication
Rules of Simple Design
 •Passes Tests
 • Removes Duplication
 • Increases Clarity
Rules of Simple Design
 •Passes Tests
 • Removes Duplication
 • Increases Clarity
 • Is Small
Rules of Simple Design

 • Removes Duplication
 • Increases Clarity
Rules of Simple Design

 • DRY
 • Clear
“The main thing that
distinguishes legacy
code from non-legacy
  code is tests, or
   rather a lack of
        tests.”
 - Michael Feathers
Safety
Sense of Progress
Documentation
Living Documentation
Design
“The act of writing a
 unit test is more an
     act of design
than of verification”
 - “Uncle” Bob Martin
RED




Your test should fail.
Write just enough code
   to make it pass.
RED   GREEN
Refactor to remove
  duplication and
 Improve clarity.
RED              GREEN




      REFACTOR
RED              GREEN




      REFACTOR
Write another test
closures
closures are expressions, usually functions, which
can work with variables set within a certian context
prototype
Writing Views Twice
Writing Views Twice
usernameDiv.text(tweet.username)
Writing Views Twice
usernameDiv.text(tweet.username)


<div id=”username”>
 <%=Model.UserName%>
</div>
“The first rule of functions is that they should
be small. The second rule of functions is that
they should be smaller than that. “- Bob
Martin, Clean Code
•   var
•var
• small functions
•var
• small functions
• isolate selectors/dom
•var
• small functions
• isolate selectors/dom
• beware closures
•var
• small functions
• isolate selectors/dom
• beware closures
• keep views dry
•var
• small functions
• isolate selectors/dom
• beware closures
• keep views dry
• test! (and ci)
Questions?

                       Len Smith
                           @ignu
                    http://iggy.nu
             len.smith@live.com

Contenu connexe

Similaire à JavaScript is Real Code

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 downDaniel Irvine
 
GoLang - Why It Matters
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Mattersrahul
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptTroy Miles
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to JavaAathikaJava
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to JavaDeeptiJava
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampTheo Jungeblut
 
Multithreading in C# - pitfalls, mistakes and solutions. Goyello Olivia Tech ...
Multithreading in C# - pitfalls, mistakes and solutions. Goyello Olivia Tech ...Multithreading in C# - pitfalls, mistakes and solutions. Goyello Olivia Tech ...
Multithreading in C# - pitfalls, mistakes and solutions. Goyello Olivia Tech ...Kasia Horsten-Szemro
 
Devopsdays london: Let’s talk about security
Devopsdays london:  Let’s talk about securityDevopsdays london:  Let’s talk about security
Devopsdays london: Let’s talk about securityJustin Cormack
 
It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecGiulio De Donato
 
Android Test Driven Development
Android Test Driven DevelopmentAndroid Test Driven Development
Android Test Driven DevelopmentArif Huda
 
Agile JavaScript Testing
Agile JavaScript TestingAgile JavaScript Testing
Agile JavaScript TestingScott Becker
 
Serverless Reality
Serverless RealityServerless Reality
Serverless RealityLynn Langit
 
Node.js Anti-Patterns and bad practices
Node.js Anti-Patterns and bad practicesNode.js Anti-Patterns and bad practices
Node.js Anti-Patterns and bad practicesIgor Soarez
 
Detangling Your JavaScript
Detangling Your JavaScriptDetangling Your JavaScript
Detangling Your JavaScriptChris Powers
 
Patterns, Code Smells, and The Pragmattic Programmer
Patterns, Code Smells, and The Pragmattic ProgrammerPatterns, Code Smells, and The Pragmattic Programmer
Patterns, Code Smells, and The Pragmattic ProgrammerJason McCreary
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean CodingMetin Ogurlu
 

Similaire à JavaScript is Real Code (20)

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
 
GoLang - Why It Matters
GoLang -  Why It MattersGoLang -  Why It Matters
GoLang - Why It Matters
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
Clean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code CampClean Code Part III - Craftsmanship at SoCal Code Camp
Clean Code Part III - Craftsmanship at SoCal Code Camp
 
Multithreading in C# - pitfalls, mistakes and solutions. Goyello Olivia Tech ...
Multithreading in C# - pitfalls, mistakes and solutions. Goyello Olivia Tech ...Multithreading in C# - pitfalls, mistakes and solutions. Goyello Olivia Tech ...
Multithreading in C# - pitfalls, mistakes and solutions. Goyello Olivia Tech ...
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Devopsdays london: Let’s talk about security
Devopsdays london:  Let’s talk about securityDevopsdays london:  Let’s talk about security
Devopsdays london: Let’s talk about security
 
It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspec
 
Android Test Driven Development
Android Test Driven DevelopmentAndroid Test Driven Development
Android Test Driven Development
 
Agile JavaScript Testing
Agile JavaScript TestingAgile JavaScript Testing
Agile JavaScript Testing
 
Serverless Reality
Serverless RealityServerless Reality
Serverless Reality
 
Node.js Anti-Patterns and bad practices
Node.js Anti-Patterns and bad practicesNode.js Anti-Patterns and bad practices
Node.js Anti-Patterns and bad practices
 
Detangling Your JavaScript
Detangling Your JavaScriptDetangling Your JavaScript
Detangling Your JavaScript
 
Patterns, Code Smells, and The Pragmattic Programmer
Patterns, Code Smells, and The Pragmattic ProgrammerPatterns, Code Smells, and The Pragmattic Programmer
Patterns, Code Smells, and The Pragmattic Programmer
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
 

Dernier

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Dernier (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

JavaScript is Real Code

Notes de l'éditeur

  1. Who Uses JS? What do you use it for? ** RIGHT, THE WE...
  2. MVC vs Controls. Flash vs. Smartphones... Decade and a half and gaining momentum. *** But JavaScript&amp;#x2019;s expanding outside of the web...
  3. Document DB. Querying, Storage all in JS. node.js: Async. Really, really, really fast. ** PICTURE ON TWITTERS
  4. JavaScript the Bad Parts is obviously a large book. Good Parts only JS book I recommend ** WRITTEN BY
  5. Godfather of JavaScript. JSON. JSLint. JSMin. *** TALKS ABOUT WHY JS MAKES US FEEL LIKE
  6. most misunderstood language in the world. *** What we really hate...
  7. Not Dom Delouise. But he doesn&amp;#x2019;t help anything. *** THE DOM
  8. *** The other problem is our fault
  9. TOY Clojure/Scala ***
  10. Why don&amp;#x2019;t we learn it? Marketing: Java - a lie Alerts ** So.... what makes JS different?
  11. DEMO *** JavaScript is Powerful, Dangerous.
  12. Stan Lee taught us *** So how do we write maintainable code
  13. Robert C. Martin
  14. List of Principles Some Important... some not. *** BUT WHY?
  15. If I lost some of you on what SOLID is, don&amp;#x2019;t worry much. Just remember, DRY AND CLEAR. Words are so simple but so difficult to achieve. What practice can force us down this path.
  16. DRY: If my function does A and B and C... B Somewhere else CLEAR: can name it B
  17. If I can extend it with out modifying I&amp;#x2019;m probably clear. And I stay dry by not having this new functions concerns bleeding into things I&amp;#x2019;m extending
  18. CLEAR: Animal that can walk sometimes but not in these cases
  19. Clear how to use this
  20. CLEAR: Animal that can walk sometimes but not in these cases
  21. Clear on what I need. Testing.
  22. In Web Applications,we typically finad
  23. Manual Testing is Immoral. Unit Tests should be %100. Crisis of Faith with dynamic languages and Cross Testing and Integration Tests. Situational Tests should just test all of these connections.
  24. Mouthfull. Using JavaScript correctly, using TDD. Synergistic.
  25. Who Uses JS? What do you use it for? ** RIGHT, THE WE...