Event4   better javascript
Upcoming SlideShare
Loading in...5
×
 

Event4 better javascript

on

  • 249 views

 

Statistics

Views

Total Views
249
Views on SlideShare
249
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Event4   better javascript Event4 better javascript Presentation Transcript

  • Write Better Javascript Event #4 Aymeric Gaurat Apelli Senior Developer
  • Who am I? Why a “Who am I?” • Aymeric Gaurat-Apelli • .NET developer/consultant since first beta • Worked in France, Australia (Readify) and Thailand • Web entrepreneur • Facebook games (1M users/day) • http://taskarmy.com • http://weekplan.net (knockout.js SPA) • Principal developer at Jetabroad (Thailand)
  • “Classes” Yes you can… kind of. Want inheritance? http://ejohn.org/blog/simple-javascript-inheritance/
  • Coding principles They apply to Javascript too! DRY Don’t repeat yourself KISS Simplicity (and avoiding complexity) should always be a key goal. YAGNI You aren’t going to need it.
  • Coding principles LAW OF DEMETER Code components should only communicate with their direct relations SRP A component of code (e.g. class or function) should perform a single well defined task. DEPENDENCY INJECTION Depend upon Abstractions. Do not depend upon Concretions.
  • How would you rewrite this code? Suggestion: http://jsfiddle.net/XejEY/1/
  • Javascript Frameworks More structure for your code Check out http://todomvc.com/
  • Templating engines Allow you to reuse snippets of HTML and to bind it to your data http://jsfiddle.net/aPv9H/1/ Choose a template engine Fast templating engine.
  • Scope There is no block level scope. A bit different from C# http://madebyknight.com/javascript-scope/ http://jsfiddle.net/Ukv2R/1/
  • Modules The solution to spaghetti code
  • Sample home grown module
  • AMD, the standard. Popular AMD module loader: requirejs
  • Dependencies versus events
  • Dependencies versus events After refactoring Router.js module
  • Unit testing http://qunitjs.com/intro/ http://pivotal.github.io/jasmine/
  • Random tips 1. Link to your javascript code at the end of your HTML document 2. Bundle and minify 3. Work with css classes instead of working with styling/animations Example
  • Resources to learn http://microjs.com/ Fantastic micro libraries to use and learn from http://dailyjs.com Blog about new stuff in the Javascript world http://terrariumjs.wiselabs.net http://github.com Search for javascript projects
  • Thank you