Javascript
for multi disciplinary teams

101
Francisco M.S. Ferreira
Software Engineer at eBay

I present my own opinion and point of view, not the one of my employer.
Why use Java?

•
•
•
•
•

Used everywhere (allegedly)
Strongly typed language

Compiled language
Object Oriented

Tons of ...
Why use JavaScript?

•
•
•
•
•

Used everywhere (allegedly)
Strongly typed language

Compiled language
Object Oriented

To...
Why use JavaScript?

•
•
•
•
•
•

Used everywhere (allegedly)
Strongly typed language

Compiled language
Object Oriented

...
Typical team
Typical team

Front End

Back End
What to expect

• An intro to JavaScript
o Simulate Object-Oriented JavaScript

• Packaging / Folder structure
• Known wal...
Java class
Flexibility
Flexibility
My favorite
Fool proof

Private variables

Public functions
Tastes like Java
Step by step
Private variables
Public variables
Private functions
Public functions
Static variables
Static functions
Feels object oriented

No private statics
What about extensions?
What about extensions?
If JS was java…
Let’s apply
What happened there

• When calling apply or call:
o
o
o
o

The this scope is shared between functions
Allows multiple inh...
What happened there

• When calling apply or call:
o
o
o
o

The this scope is shared between functions
Allows multiple inh...
What happened there

• When calling apply or call:
o
o
o
o

The this scope is shared between functions
Allows multiple inh...
Folder naming
Java packages
Folder naming
Java packages

JavaScript folders
The three big walls of JS

•JavaScript is not type safe!

•JavaScript is single threaded!
•Lot’s of callbacks with closure...
Javascript !== TypeSafe
If you use:
===
!==
All these
would be
false
Equality of objects is deep
•

Recursively compare all elements

•

If order is guaranteed:
o JSON.stringify && compare JS...
Single Threaded!
setTimeout
someOtherCode
moreCode
...

aCallback
Mountain of Doom

• Hard to read
o And maintain

• Callback hell
• Issues
o
o
o
o

Memory Leaks
Error prone
Hard to debug
...
Q&A
Upcoming SlideShare
Loading in …5
×

JS for multidisciplinary teams

1,687 views

Published on

jDays.se presentation

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

No Downloads
Views
Total views
1,687
On SlideShare
0
From Embeds
0
Number of Embeds
1,063
Actions
Shares
0
Downloads
1
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

JS for multidisciplinary teams

  1. 1. Javascript for multi disciplinary teams 101
  2. 2. Francisco M.S. Ferreira Software Engineer at eBay I present my own opinion and point of view, not the one of my employer.
  3. 3. Why use Java? • • • • • Used everywhere (allegedly) Strongly typed language Compiled language Object Oriented Tons of available frameworks
  4. 4. Why use JavaScript? • • • • • Used everywhere (allegedly) Strongly typed language Compiled language Object Oriented Tons of available frameworks
  5. 5. Why use JavaScript? • • • • • • Used everywhere (allegedly) Strongly typed language Compiled language Object Oriented Tons of available frameworks Extremely flexible
  6. 6. Typical team
  7. 7. Typical team Front End Back End
  8. 8. What to expect • An intro to JavaScript o Simulate Object-Oriented JavaScript • Packaging / Folder structure • Known walls new developers hit o Type safety o Single threaded system o Mountain/Piramid of doom.
  9. 9. Java class
  10. 10. Flexibility
  11. 11. Flexibility
  12. 12. My favorite Fool proof Private variables Public functions
  13. 13. Tastes like Java
  14. 14. Step by step
  15. 15. Private variables
  16. 16. Public variables
  17. 17. Private functions
  18. 18. Public functions
  19. 19. Static variables
  20. 20. Static functions
  21. 21. Feels object oriented No private statics
  22. 22. What about extensions?
  23. 23. What about extensions?
  24. 24. If JS was java…
  25. 25. Let’s apply
  26. 26. What happened there • When calling apply or call: o o o o The this scope is shared between functions Allows multiple inheritances Allows order of execution in inheritances Directly inherits!
  27. 27. What happened there • When calling apply or call: o o o o The this scope is shared between functions Allows multiple inheritances Allows order of execution in inheritances Directly inherits! • It only shares: o ‘public’ functions and variables
  28. 28. What happened there • When calling apply or call: o o o o The this scope is shared between functions Allows multiple inheritances Allows order of execution in inheritances Directly inherits! • It only shares: o ‘public’ functions and variables • It may overwrite methods or get overwritten
  29. 29. Folder naming Java packages
  30. 30. Folder naming Java packages JavaScript folders
  31. 31. The three big walls of JS •JavaScript is not type safe! •JavaScript is single threaded! •Lot’s of callbacks with closures!
  32. 32. Javascript !== TypeSafe If you use: === !== All these would be false
  33. 33. Equality of objects is deep • Recursively compare all elements • If order is guaranteed: o JSON.stringify && compare JSONs • Use deep compare function ≈ 120 lines of code o http://stackoverflow.com/questions/1068834/object-comparison-in-javascript
  34. 34. Single Threaded! setTimeout someOtherCode moreCode ... aCallback
  35. 35. Mountain of Doom • Hard to read o And maintain • Callback hell • Issues o o o o Memory Leaks Error prone Hard to debug Hard to test
  36. 36. Q&A

×