Taming complexity in JavaScript
-
Upload
binary-studio -
Category
Software
-
view
94 -
download
1
Transcript of Taming complexity in JavaScript
Taming complexity in JavaScriptMykyta Semenistyi
Mykyta Semenistyi
@msemenistyi
Tech LeadBinaryStudio
http://www.binary-studio.com/
C# JS
Enterprise Startup
The art of programming is the art of organizing complexity, of mastering multitude and avoiding its bastard chaos as effectively as possible.
Edsger W. Dijkstra
Ubiquitous state
Managing state is hard
Server responsesCached dataLocally generated dataUI data
jQuery
AngularChild Controller + Parent controllers chain
Markup
Flux -> Redux
Immutability
reducer (oldState) -> newState
Pure functions
Pure functions
Asynchronicity
UI Thread
...onclick XHR state change
setTimeout setInterval
onclick XHR state change
setTimeout
Event Loop
Callback hell
Async
Async
Promises
Promises
GeneratorsOutput ->
<- Input
Generators - Coroutines
Async await
API implicitness
Implementation implicitness
Digest loops
Directives
Scope inheritance
DSL - Webpack
Inheritance
Favor aggregation over inheritance Go
F
Custom implementations
leftpad
Outtakes
There are people behind npm modules
People happen to be assholes
Npm has fixed the issue within hours
Npm has updated its policy of unpublishing
Why?
Waste of time
High probability of bugs
No bugfixes and upgrades from others
Selecting tools
Be aware
Avoid JavaScript fatigue
Consider ecosystem
Signal vs NoisejQuery - DOM API Backbone - UI Architecture
Code inconsistency
CoffeeScript
TypeScript
ES2015
Linters
Flow
BE CONSISTENT.
If you're editing code, take a few minutes to look at the code around you and determine its style. If they use spaces around all their arithmetic operators, you should too. If their comments have little boxes of hash marks around them, make your comments have little boxes of hash marks around them too.
Google JS Styleguide
Recap
Tame state
Use modern approaches for asynchronicity
Prefer composition
Don’t try to invent you language - use JS
Utilize what others have created
Choose tools wisely
Use tools if necessary
Love JS
yield ‘end’;