JavaScript is Real Code

1,237 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,237
On SlideShare
0
From Embeds
0
Number of Embeds
316
Actions
Shares
0
Downloads
17
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Who Uses JS? What do you use it for?
    ** RIGHT, THE WE...
  • MVC vs Controls.
    Flash vs. Smartphones...
    Decade and a half and gaining momentum.
    *** But JavaScript’s expanding outside of the web...


  • Document DB. Querying, Storage all in JS.
    node.js: Async. Really, really, really fast.
    ** PICTURE ON TWITTERS
  • JavaScript the Bad Parts is obviously a large book.
    Good Parts only JS book I recommend
    ** WRITTEN BY
  • Godfather of JavaScript.
    JSON. JSLint. JSMin.
    *** TALKS ABOUT WHY JS MAKES US FEEL LIKE
  • most misunderstood language in the world.
    *** What we really hate...
  • Not Dom Delouise.
    But he doesn’t help anything.
    *** THE DOM
  • *** The other problem is our fault
  • TOY
    Clojure/Scala
    ***
  • Why don’t we learn it?
    Marketing: Java - a lie
    Alerts
    ** So.... what makes JS different?


  • DEMO
    *** JavaScript is Powerful, Dangerous.


  • Stan Lee taught us
    *** So how do we write maintainable code

  • Robert C. Martin
  • List of Principles
    Some Important... some not.
    *** BUT WHY?
  • If I lost some of you on what SOLID is, don’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.

  • DRY: If my function does A and B and C... B Somewhere else
    CLEAR: can name it B









  • If I can extend it with out modifying I’m probably clear. And I stay dry by not having this new functions concerns bleeding into things I’m extending


  • CLEAR: Animal that can walk sometimes but not in these cases
  • Clear how to use this
  • CLEAR: Animal that can walk sometimes but not in these cases


  • Clear on what I need. Testing.













  • In Web Applications,we typically finad















  • 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.
  • Mouthfull.
    Using JavaScript correctly, using TDD. Synergistic.







  • Who Uses JS? What do you use it for?
    ** RIGHT, THE WE...
  • JavaScript is Real Code

    1. 1. JavaScript is Real Code Len Smith @ignu http://iggy.nu len.smith@live.com
    2. 2. Document Object Model
    3. 3. “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
    4. 4. Dynamic
    5. 5. Loose Typing
    6. 6. number boolean string undefined object Regex Date Array
    7. 7. “Lisp in C’s clothing”
    8. 8. function() {}
    9. 9. SOLID?
    10. 10. Single Responsibility Principle Open Closed Principle Liskov Substitution Principle Interface Segregation Principle Dependency Inversion Principle
    11. 11. JavaScript Isn’t Shouldn’t be OO
    12. 12. Rules of Simple Design
    13. 13. Rules of Simple Design • Passes Tests
    14. 14. Rules of Simple Design •Passes Tests • Removes Duplication
    15. 15. Rules of Simple Design •Passes Tests • Removes Duplication • Increases Clarity
    16. 16. Rules of Simple Design •Passes Tests • Removes Duplication • Increases Clarity • Is Small
    17. 17. Rules of Simple Design • Removes Duplication • Increases Clarity
    18. 18. Rules of Simple Design • DRY • Clear
    19. 19. “The main thing that distinguishes legacy code from non-legacy code is tests, or rather a lack of tests.” - Michael Feathers
    20. 20. Safety
    21. 21. Sense of Progress
    22. 22. Documentation
    23. 23. Living Documentation
    24. 24. Design
    25. 25. “The act of writing a unit test is more an act of design than of verification” - “Uncle” Bob Martin
    26. 26. RED Your test should fail.
    27. 27. Write just enough code to make it pass.
    28. 28. RED GREEN
    29. 29. Refactor to remove duplication and Improve clarity.
    30. 30. RED GREEN REFACTOR
    31. 31. RED GREEN REFACTOR
    32. 32. Write another test
    33. 33. closures
    34. 34. closures are expressions, usually functions, which can work with variables set within a certian context
    35. 35. prototype
    36. 36. Writing Views Twice
    37. 37. Writing Views Twice usernameDiv.text(tweet.username)
    38. 38. Writing Views Twice usernameDiv.text(tweet.username) <div id=”username”> <%=Model.UserName%> </div>
    39. 39. “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
    40. 40. • var
    41. 41. •var • small functions
    42. 42. •var • small functions • isolate selectors/dom
    43. 43. •var • small functions • isolate selectors/dom • beware closures
    44. 44. •var • small functions • isolate selectors/dom • beware closures • keep views dry
    45. 45. •var • small functions • isolate selectors/dom • beware closures • keep views dry • test! (and ci)
    46. 46. Questions? Len Smith @ignu http://iggy.nu len.smith@live.com

    ×