SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
Beautiful Javascript
                       with
                  Coffeescript
                  with Amir Barylko




Amir Barylko                    Advanced Design Patterns
WHO AM I?

  • Software     quality expert

  • Architect

  • Developer

  • Mentor

  • Great      cook

  • The    one who’s entertaining you for the next hour!
Amir Barylko                                               Beautiful JS with CS
RESOURCES

  • Email: amir@barylko.com

  • Twitter: @abarylko

  • Blog: http://www.orthocoders.com

  • Materials: http://www.orthocoders.com/presentations




Amir Barylko                                          Beautiful JS with CS
COFFEESCRIPT




Amir Barylko                  Beautiful JS with CS
WHAT’S WRONG WITH JS

  • Too    verbose (too many { and } )
  • Global Variables

  • Lacks      support for classes
  • Hard       to make inheritance
  • Automatic       type conversion between strings and numbers
  • NaN        is not a number, however it is a number

Amir Barylko                                             Beautiful JS with CS
WHAT IS IT?

    “CoffeeScript is a little language that compiles
    into JavaScript. Underneath all those awkward
    braces and semicolons, JavaScript has always
    had a gorgeous object model at its heart.
    CoffeeScript is an attempt to expose the good
    parts of JavaScript in a simple way.”



                  http://coffeescript.org/
Amir Barylko                                 Beautiful JS with CS
STRING INTERPOLATION

  • You  can concatenate inside a double quote string
    using the “#” and “{ }”
    "The result is #{3}" == "The result is 3"

  • Or     use any expression
    "/movies/#{id}"


Amir Barylko                                 Beautiful JS with CS
FUNCTIONS

  • The        arrow/lambda defines functions
    square = (x) -> x * x


  • Parenthesis     are optional when passing
    parameters
     storageDelete movieId, true



Amir Barylko                                    Beautiful JS with CS
FUNCTIONS II

  • Implicit   return
    (the last expression is the return value)


  •Multiple    lines, indentation is important
    deleteMovie = (e) ->
      movieId = $(e.target)....
      storageDelete(movieId)


Amir Barylko                                     Beautiful JS with CS
OBJECTS AS HASHES

  • Declared    using indentation
     config =
       local:
         user:    'dev'
         pwd:     'dev123'
       remote:
         user:    'superdev'
         pwd:     "impossibleToGuess"


Amir Barylko                            Beautiful JS with CS
ARRAYS

  • Arrays     are declared with “[ ]”
    deploy = ['local', 'remote', 'uat']
    fib = [1, 3, 5, 8, 13, 21]

  • Slicing
    first = fib[0..3]
    noLast = fib[0..-2]

Amir Barylko                              Beautiful JS with CS
DESTRUCTURING
                 ASSIGNMENT
  • Multiple   assignments
    [firstName, nick, last] = ['D'Arcy', 'Baconator', 'Lussier']


  • Splat
    reviews = [45, 29, 21, 10, 8, 4]

    [best, secondBest, theRest...] = reviews




Amir Barylko                                              Beautiful JS with CS
CONDITIONALS

  • Classic    if does not need parenthesis
    if isJson
      callIndex()
      display()
    else
      showMessage()

  • Or     use unless for the negated form


Amir Barylko                                  Beautiful JS with CS
MODIFIERS

  • The        conditionals can be use as modifiers
    callIndex() if isJson
    exit() unless validated and inContext




Amir Barylko                                         Beautiful JS with CS
SWITCH

  • Selects    between multiple conditions
    movieReview = (critic, movie) ->
      switch critic
        when 'Jay'
          'It Stinks!'
        when 'Darcy'
          if movie.match(/Bacon/) then...
        else
          throw new Error('Invalid critic name!')




Amir Barylko                                   Beautiful JS with CS
LIST COMPREHENSION

  • Iterate     and call a function over each element
    deploy env for env in ['local', 'uat', 'prod']


  • Or     filter over a collection
    nums = (num for num in [1..960] when isInteger(960 / num))




Amir Barylko                                              Beautiful JS with CS
EXISTENTIAL OPERATOR

  • Checks     if a variable is null or undefined
    question = paragraph? and not createdDate?
    defaultValue ?= 5

    precendence = first ? 5



  • It   can be used to avoid TypeError exception
    extension = secondaryAddress?().phone?.extension




Amir Barylko                                           Beautiful JS with CS
CLASSES

  class MovieRepository

      constructor: (@baseUrl) ->

      newMovie: ->
        $.ajax
          url: "#{@baseUrl}/movies/create"
          success: (data) -> $(id).append data




Amir Barylko                             Beautiful JS with CS
INHERITANCE

  • One        class can extend another
    class Shape
       constructor: (@width) ->

    class Square extends Shape
      computeArea: -> Math.pow @width, 2

    class Circle extends Shape
      radius: -> @width / 2
      computeArea: -> Math.PI * Math.pow @radius(), 2


Amir Barylko                                   Beautiful JS with CS
COMPLAINS
                (Go ahead, say it)




Amir Barylko                         Beautiful JS with CS
I ALREADY KNOW JS

  •Continuous          learning
  •Benefits         outweigh effort
  •Generates          way better code
  •Do          your duty as developer!
Amir Barylko                             Beautiful JS with CS
EXTRA COMPILATION STEP

  • .NET       and Java frameworks will do it for you
  • Or  tools will watch your folder and generate it
    for you
  • Hardly      notice the extra work



Amir Barylko                                      Beautiful JS with CS
DEBUGGING IS HARD

  • Same         variable names
  • Just       set a breakpoint in the code
  • and        add watches, etc....




Amir Barylko                                  Beautiful JS with CS
TESTING & 3RD PARTY

  • Is   just Javascript
  • so    use Jasmine
  • or    Qunit
  • any        other....



Amir Barylko                      Beautiful JS with CS
QUESTIONS?




Amir Barylko                Advanced Design Patterns
RESOURCES
  •   Email: amir@barylko.com, @abarylko

  •   Slides & Source: http://www.orthocoders.com/presentations

  •   http://coffeescript.org

  •   https://github.com/sleepyfox/coffeescript-koans

  •   http://pivotal.github.com/jasmine/

  •   http://qunitjs.com/

  •   http://nodejs.org/
Amir Barylko                                                      Beautiful JS with CS
RESOURCES II




Amir Barylko                  Beautiful JS with CS

Más contenido relacionado

La actualidad más candente

C# Powershell and an Azure Function Walk Into a Bar...
C# Powershell and an Azure Function Walk Into a Bar... C# Powershell and an Azure Function Walk Into a Bar...
C# Powershell and an Azure Function Walk Into a Bar... Obilogic
 
Aae jv presentation
Aae jv presentationAae jv presentation
Aae jv presentationpaininbutt
 
JSLink for ITPros - SharePoint Saturday Jersey
JSLink for ITPros - SharePoint Saturday JerseyJSLink for ITPros - SharePoint Saturday Jersey
JSLink for ITPros - SharePoint Saturday JerseyPaul Hunt
 
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationLose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationJeremy Ward
 
Business Follies
Business FolliesBusiness Follies
Business FolliesTOKA
 
Famo.us introduction
Famo.us introductionFamo.us introduction
Famo.us introductionAllen Wu
 
Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme FrameworkJoe Casabona
 
PG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & HybridPG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & HybridAlex Blom
 
AMAZON PRODUCT LISTING OPRIMIZATION
AMAZON PRODUCT LISTING OPRIMIZATIONAMAZON PRODUCT LISTING OPRIMIZATION
AMAZON PRODUCT LISTING OPRIMIZATIONDanicaDaas
 

La actualidad más candente (12)

C# Powershell and an Azure Function Walk Into a Bar...
C# Powershell and an Azure Function Walk Into a Bar... C# Powershell and an Azure Function Walk Into a Bar...
C# Powershell and an Azure Function Walk Into a Bar...
 
Aae jv presentation
Aae jv presentationAae jv presentation
Aae jv presentation
 
JSLink for ITPros - SharePoint Saturday Jersey
JSLink for ITPros - SharePoint Saturday JerseyJSLink for ITPros - SharePoint Saturday Jersey
JSLink for ITPros - SharePoint Saturday Jersey
 
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content PresentationLose Your Head! Re-imagining WordPress's Role in Content Presentation
Lose Your Head! Re-imagining WordPress's Role in Content Presentation
 
Business Follies
Business FolliesBusiness Follies
Business Follies
 
Famo.us introduction
Famo.us introductionFamo.us introduction
Famo.us introduction
 
Testing Alexa Skill
Testing Alexa SkillTesting Alexa Skill
Testing Alexa Skill
 
Intro to EmberJS
Intro to EmberJSIntro to EmberJS
Intro to EmberJS
 
Building a Simple Theme Framework
Building a Simple Theme FrameworkBuilding a Simple Theme Framework
Building a Simple Theme Framework
 
PG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & HybridPG Day Us: Animations for Web & Hybrid
PG Day Us: Animations for Web & Hybrid
 
Fastest css3 animations
Fastest css3 animations Fastest css3 animations
Fastest css3 animations
 
AMAZON PRODUCT LISTING OPRIMIZATION
AMAZON PRODUCT LISTING OPRIMIZATIONAMAZON PRODUCT LISTING OPRIMIZATION
AMAZON PRODUCT LISTING OPRIMIZATION
 

Destacado

Codemash-iron-ruby-match-made-in-heaven
Codemash-iron-ruby-match-made-in-heavenCodemash-iron-ruby-match-made-in-heaven
Codemash-iron-ruby-match-made-in-heavenAmir Barylko
 
SDEC10-Bdd-quality-driven
SDEC10-Bdd-quality-drivenSDEC10-Bdd-quality-driven
SDEC10-Bdd-quality-drivenAmir Barylko
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web developmentAmir Barylko
 
Paso a Paso para construir un marco teórico
 Paso a Paso para construir un marco teórico Paso a Paso para construir un marco teórico
Paso a Paso para construir un marco teóricoJosé Davidd Meza
 

Destacado (9)

Groningen rb #2 bdd
Groningen rb #2 bddGroningen rb #2 bdd
Groningen rb #2 bdd
 
4.4 final PPP
4.4 final PPP4.4 final PPP
4.4 final PPP
 
Phpmatsuri2010
Phpmatsuri2010Phpmatsuri2010
Phpmatsuri2010
 
Codemash-iron-ruby-match-made-in-heaven
Codemash-iron-ruby-match-made-in-heavenCodemash-iron-ruby-match-made-in-heaven
Codemash-iron-ruby-match-made-in-heaven
 
Sass & bootstrap
Sass & bootstrapSass & bootstrap
Sass & bootstrap
 
SDEC10-Bdd-quality-driven
SDEC10-Bdd-quality-drivenSDEC10-Bdd-quality-driven
SDEC10-Bdd-quality-driven
 
Elm: delightful web development
Elm: delightful web developmentElm: delightful web development
Elm: delightful web development
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
Paso a Paso para construir un marco teórico
 Paso a Paso para construir un marco teórico Paso a Paso para construir un marco teórico
Paso a Paso para construir un marco teórico
 

Similar a Beutiful javascript with coffeescript

PRDC12 advanced design patterns
PRDC12 advanced design patternsPRDC12 advanced design patterns
PRDC12 advanced design patternsAmir Barylko
 
PRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsPRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsAmir Barylko
 
A baryklo design-patterns
A baryklo design-patternsA baryklo design-patterns
A baryklo design-patternssdeconf
 
sdec11-Advanced-design-patterns
sdec11-Advanced-design-patternssdec11-Advanced-design-patterns
sdec11-Advanced-design-patternsAmir Barylko
 
Hi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextHi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextMugunth Kumar
 
Infrastructure as Code on Azure: Show your Bicep!
Infrastructure as Code on Azure: Show your Bicep!Infrastructure as Code on Azure: Show your Bicep!
Infrastructure as Code on Azure: Show your Bicep!Marco Obinu
 
CSS workshop @ OutSystems
CSS workshop @ OutSystemsCSS workshop @ OutSystems
CSS workshop @ OutSystemsRuben Goncalves
 
Spring framework
Spring frameworkSpring framework
Spring frameworkAircon Chen
 
Артем Яворский "Compile like it's 2017"
Артем Яворский "Compile like it's 2017"Артем Яворский "Compile like it's 2017"
Артем Яворский "Compile like it's 2017"Fwdays
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and PointersMichael Heron
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application DesignBryce Kerley
 
Be German About Your Frontend
Be German About Your FrontendBe German About Your Frontend
Be German About Your FrontendArush Sehgal
 
Image Classification and Retrieval on Spark
Image Classification and Retrieval on SparkImage Classification and Retrieval on Spark
Image Classification and Retrieval on SparkGianvito Siciliano
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma Christopher Bartling
 

Similar a Beutiful javascript with coffeescript (20)

PRDC12 advanced design patterns
PRDC12 advanced design patternsPRDC12 advanced design patterns
PRDC12 advanced design patterns
 
PRDCW-advanced-design-patterns
PRDCW-advanced-design-patternsPRDCW-advanced-design-patterns
PRDCW-advanced-design-patterns
 
A baryklo design-patterns
A baryklo design-patternsA baryklo design-patterns
A baryklo design-patterns
 
sdec11-Advanced-design-patterns
sdec11-Advanced-design-patternssdec11-Advanced-design-patterns
sdec11-Advanced-design-patterns
 
Hi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreTextHi performance table views with QuartzCore and CoreText
Hi performance table views with QuartzCore and CoreText
 
Infrastructure as Code on Azure: Show your Bicep!
Infrastructure as Code on Azure: Show your Bicep!Infrastructure as Code on Azure: Show your Bicep!
Infrastructure as Code on Azure: Show your Bicep!
 
CSS workshop @ OutSystems
CSS workshop @ OutSystemsCSS workshop @ OutSystems
CSS workshop @ OutSystems
 
Building a spa_in_30min
Building a spa_in_30minBuilding a spa_in_30min
Building a spa_in_30min
 
Building a spa_in_30min
Building a spa_in_30minBuilding a spa_in_30min
Building a spa_in_30min
 
Jquery2012 defs
Jquery2012 defsJquery2012 defs
Jquery2012 defs
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Design Without Types
Design Without TypesDesign Without Types
Design Without Types
 
Артем Яворский "Compile like it's 2017"
Артем Яворский "Compile like it's 2017"Артем Яворский "Compile like it's 2017"
Артем Яворский "Compile like it's 2017"
 
Css 3
Css 3Css 3
Css 3
 
Css 3
Css 3Css 3
Css 3
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 
Be German About Your Frontend
Be German About Your FrontendBe German About Your Frontend
Be German About Your Frontend
 
Image Classification and Retrieval on Spark
Image Classification and Retrieval on SparkImage Classification and Retrieval on Spark
Image Classification and Retrieval on Spark
 
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
 

Más de Amir Barylko

Functional converter project
Functional converter projectFunctional converter project
Functional converter projectAmir Barylko
 
User stories deep dive
User stories deep diveUser stories deep dive
User stories deep diveAmir Barylko
 
Coderetreat hosting training
Coderetreat hosting trainingCoderetreat hosting training
Coderetreat hosting trainingAmir Barylko
 
There's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessThere's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessAmir Barylko
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6Amir Barylko
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?Amir Barylko
 
From coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideFrom coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideAmir Barylko
 
Communication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityCommunication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityAmir Barylko
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven DevelopmentAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 
Agile teams and responsibilities
Agile teams and responsibilitiesAgile teams and responsibilities
Agile teams and responsibilitiesAmir Barylko
 
Agile requirements
Agile requirementsAgile requirements
Agile requirementsAmir Barylko
 
Cpl12 continuous integration
Cpl12 continuous integrationCpl12 continuous integration
Cpl12 continuous integrationAmir Barylko
 
Teams and responsibilities
Teams and responsibilitiesTeams and responsibilities
Teams and responsibilitiesAmir Barylko
 
Open source libraries and tools
Open source libraries and toolsOpen source libraries and tools
Open source libraries and toolsAmir Barylko
 

Más de Amir Barylko (20)

Functional converter project
Functional converter projectFunctional converter project
Functional converter project
 
No estimates
No estimatesNo estimates
No estimates
 
User stories deep dive
User stories deep diveUser stories deep dive
User stories deep dive
 
Coderetreat hosting training
Coderetreat hosting trainingCoderetreat hosting training
Coderetreat hosting training
 
There's no charge for (functional) awesomeness
There's no charge for (functional) awesomenessThere's no charge for (functional) awesomeness
There's no charge for (functional) awesomeness
 
What's new in c# 6
What's new in c# 6What's new in c# 6
What's new in c# 6
 
Productive teams
Productive teamsProductive teams
Productive teams
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?
 
From coach to owner - What I learned from the other side
From coach to owner - What I learned from the other sideFrom coach to owner - What I learned from the other side
From coach to owner - What I learned from the other side
 
Communication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivityCommunication is the Key to Teamwork and productivity
Communication is the Key to Teamwork and productivity
 
Acceptance Test Driven Development
Acceptance Test Driven DevelopmentAcceptance Test Driven Development
Acceptance Test Driven Development
 
Refactoring
RefactoringRefactoring
Refactoring
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 
Agile teams and responsibilities
Agile teams and responsibilitiesAgile teams and responsibilities
Agile teams and responsibilities
 
Refactoring
RefactoringRefactoring
Refactoring
 
Agile requirements
Agile requirementsAgile requirements
Agile requirements
 
Cpl12 continuous integration
Cpl12 continuous integrationCpl12 continuous integration
Cpl12 continuous integration
 
Nuget
NugetNuget
Nuget
 
Teams and responsibilities
Teams and responsibilitiesTeams and responsibilities
Teams and responsibilities
 
Open source libraries and tools
Open source libraries and toolsOpen source libraries and tools
Open source libraries and tools
 

Beutiful javascript with coffeescript

  • 1. Beautiful Javascript with Coffeescript with Amir Barylko Amir Barylko Advanced Design Patterns
  • 2. WHO AM I? • Software quality expert • Architect • Developer • Mentor • Great cook • The one who’s entertaining you for the next hour! Amir Barylko Beautiful JS with CS
  • 3. RESOURCES • Email: amir@barylko.com • Twitter: @abarylko • Blog: http://www.orthocoders.com • Materials: http://www.orthocoders.com/presentations Amir Barylko Beautiful JS with CS
  • 4. COFFEESCRIPT Amir Barylko Beautiful JS with CS
  • 5. WHAT’S WRONG WITH JS • Too verbose (too many { and } ) • Global Variables • Lacks support for classes • Hard to make inheritance • Automatic type conversion between strings and numbers • NaN is not a number, however it is a number Amir Barylko Beautiful JS with CS
  • 6. WHAT IS IT? “CoffeeScript is a little language that compiles into JavaScript. Underneath all those awkward braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.” http://coffeescript.org/ Amir Barylko Beautiful JS with CS
  • 7. STRING INTERPOLATION • You can concatenate inside a double quote string using the “#” and “{ }” "The result is #{3}" == "The result is 3" • Or use any expression "/movies/#{id}" Amir Barylko Beautiful JS with CS
  • 8. FUNCTIONS • The arrow/lambda defines functions square = (x) -> x * x • Parenthesis are optional when passing parameters storageDelete movieId, true Amir Barylko Beautiful JS with CS
  • 9. FUNCTIONS II • Implicit return (the last expression is the return value) •Multiple lines, indentation is important deleteMovie = (e) -> movieId = $(e.target).... storageDelete(movieId) Amir Barylko Beautiful JS with CS
  • 10. OBJECTS AS HASHES • Declared using indentation config = local: user: 'dev' pwd: 'dev123' remote: user: 'superdev' pwd: "impossibleToGuess" Amir Barylko Beautiful JS with CS
  • 11. ARRAYS • Arrays are declared with “[ ]” deploy = ['local', 'remote', 'uat'] fib = [1, 3, 5, 8, 13, 21] • Slicing first = fib[0..3] noLast = fib[0..-2] Amir Barylko Beautiful JS with CS
  • 12. DESTRUCTURING ASSIGNMENT • Multiple assignments [firstName, nick, last] = ['D'Arcy', 'Baconator', 'Lussier'] • Splat reviews = [45, 29, 21, 10, 8, 4] [best, secondBest, theRest...] = reviews Amir Barylko Beautiful JS with CS
  • 13. CONDITIONALS • Classic if does not need parenthesis if isJson callIndex() display() else showMessage() • Or use unless for the negated form Amir Barylko Beautiful JS with CS
  • 14. MODIFIERS • The conditionals can be use as modifiers callIndex() if isJson exit() unless validated and inContext Amir Barylko Beautiful JS with CS
  • 15. SWITCH • Selects between multiple conditions movieReview = (critic, movie) -> switch critic when 'Jay' 'It Stinks!' when 'Darcy' if movie.match(/Bacon/) then... else throw new Error('Invalid critic name!') Amir Barylko Beautiful JS with CS
  • 16. LIST COMPREHENSION • Iterate and call a function over each element deploy env for env in ['local', 'uat', 'prod'] • Or filter over a collection nums = (num for num in [1..960] when isInteger(960 / num)) Amir Barylko Beautiful JS with CS
  • 17. EXISTENTIAL OPERATOR • Checks if a variable is null or undefined question = paragraph? and not createdDate? defaultValue ?= 5 precendence = first ? 5 • It can be used to avoid TypeError exception extension = secondaryAddress?().phone?.extension Amir Barylko Beautiful JS with CS
  • 18. CLASSES class MovieRepository constructor: (@baseUrl) -> newMovie: -> $.ajax url: "#{@baseUrl}/movies/create" success: (data) -> $(id).append data Amir Barylko Beautiful JS with CS
  • 19. INHERITANCE • One class can extend another class Shape constructor: (@width) -> class Square extends Shape computeArea: -> Math.pow @width, 2 class Circle extends Shape radius: -> @width / 2 computeArea: -> Math.PI * Math.pow @radius(), 2 Amir Barylko Beautiful JS with CS
  • 20. COMPLAINS (Go ahead, say it) Amir Barylko Beautiful JS with CS
  • 21. I ALREADY KNOW JS •Continuous learning •Benefits outweigh effort •Generates way better code •Do your duty as developer! Amir Barylko Beautiful JS with CS
  • 22. EXTRA COMPILATION STEP • .NET and Java frameworks will do it for you • Or tools will watch your folder and generate it for you • Hardly notice the extra work Amir Barylko Beautiful JS with CS
  • 23. DEBUGGING IS HARD • Same variable names • Just set a breakpoint in the code • and add watches, etc.... Amir Barylko Beautiful JS with CS
  • 24. TESTING & 3RD PARTY • Is just Javascript • so use Jasmine • or Qunit • any other.... Amir Barylko Beautiful JS with CS
  • 25. QUESTIONS? Amir Barylko Advanced Design Patterns
  • 26. RESOURCES • Email: amir@barylko.com, @abarylko • Slides & Source: http://www.orthocoders.com/presentations • http://coffeescript.org • https://github.com/sleepyfox/coffeescript-koans • http://pivotal.github.com/jasmine/ • http://qunitjs.com/ • http://nodejs.org/ Amir Barylko Beautiful JS with CS
  • 27. RESOURCES II Amir Barylko Beautiful JS with CS