denis radin - "applying nasa coding guidelines to javascript or airspace is closer than you may...
TRANSCRIPT
![Page 1: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/1.jpg)
![Page 2: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/2.jpg)
Applying NASA code guidelines to JavaScript
Airspace is closer than you may think
Europa`s surface
![Page 4: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/4.jpg)
The universe respects unification
Planets shape, the laws of physics, and star system as a unit are constant everywhere
Large Magellanic Cloud
![Page 5: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/5.jpg)
“Unification — effective method to decrease diversity. Aim for unification is to place elements in particular order building strict system which is comfortable to use.”
(c) Wikipedia
Rosetta`s detination comet
![Page 6: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/6.jpg)
It can be hard to distinguish them without being an expert
There are sixtillions of standardized units...
Milky Way, Salamnca, Spain
![Page 7: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/7.jpg)
Unification never stops
The same works for engineering
ISS expedition 42 return
![Page 8: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/8.jpg)
Diversity decreases since only best
solutions survive...Is it a Boeing or Airbus?
![Page 9: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/9.jpg)
Can you distinguish them at all?
I bet you can not because of unification...
![Page 10: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/10.jpg)
But such a common thing as UI definitionis not standardized yet
We develop softwarefor 60 years
Souyz space ship docks ISS
![Page 12: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/12.jpg)
All UIs will be unified
All planetsare round
Timelapse taken from ISS
![Page 13: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/13.jpg)
Let`s guess...
Standard?
Voyager golden disks
![Page 14: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/14.jpg)
Unification, reliability, accessability
Why HTML for flight instruments?
Bombardier Q400 electronic dashboard
![Page 15: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/15.jpg)
Highly valuable in the age of drones
Network accessibility
MQ-1 Predator
![Page 16: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/16.jpg)
Decreases development cost standardizing development flow and technologies stack
Unification
Work on NASA's InSight Lander
![Page 17: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/17.jpg)
Browser is a GUI rendering system tested by billions users daily
Reliablility
NASA's Mission Control Center
![Page 18: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/18.jpg)
Possibility to establish competitive UI components (flight instruments) market
Components market
Mir station modules scheme
![Page 19: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/19.jpg)
And first ever flight using HTML/JS for displaying flight information
First HTML/JS flight instrument
Diamond aircraft DA40
![Page 20: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/20.jpg)
Live demo
Let`s try
![Page 22: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/22.jpg)
● Resources consuming efficiency● Memory leaks● GPU accelerated path● Alternative rendering methods (Canvas,
WebGL)
Pitfalls?
![Page 23: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/23.jpg)
Most likely because of your expectations from JS developers
Scared flying JS driven airplane?
![Page 24: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/24.jpg)
Trust is based on expectations on what is normal for JS
This is all about trust
![Page 25: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/25.jpg)
Let`s have a look at Jet Propulsion Laboratory
More guidelines?
JPL HQ
![Page 26: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/26.jpg)
Can your JavaScript do this?
Voyager:36 years without bugs
Voyager probe CGI
![Page 27: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/27.jpg)
![Page 28: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/28.jpg)
Performance and stability are priorities
![Page 29: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/29.jpg)
Month without a reset ?
![Page 30: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/30.jpg)
Code guidelines to the rescue...
![Page 31: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/31.jpg)
No function should be longer than what can be printed on a single sheet of paper
Rule #1
Sunrise on Saturnphoto by Cassini probe, JPL
![Page 32: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/32.jpg)
MARGARET HAMILTONnext to printed source code
of Apollo mission
![Page 33: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/33.jpg)
Long functions: less readable, not reusable, harder to test, harder to refactor
Rule #1 - Do one thing
Sunrise on Saturnphoto by Cassini probe, JPL
![Page 34: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/34.jpg)
makeCoffeeAndCookEgg(){
let teapot = new Teapot();
let cup = new Cup();
let pan = new Pan();
let egg = new Egg();
teapot.on().then(teapot.fill.bind(cup));
pan.on()
.then(egg.breake)
.then(egg.fill.bind(cup));
}
Rule #1 - Readibility
Sunrise on Saturnphoto by Cassini probe, JPL
makeCoffeeAndCookEgg(){
makeCoffee();
cookEgg();
}
makeCoffeeAndDoToast(){
makeCoffee();
doToast();
}
![Page 35: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/35.jpg)
makeCoffeeAndCookEgg(){
let teapot = new Teapot();
let cup = new Cup();
let pan = new Pan();
let egg = new Egg();
teapot.on().then(teapot.fill.bind(cup));
pan.on()
.then(egg.breake)
.then(egg.fill.bind(cup));
}
Rule #1 - Reusability
Sunrise on Saturnphoto by Cassini probe, JPL
makeCoffeeAndCookEgg(){
makeCoffee();
cookEgg();
}
![Page 36: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/36.jpg)
makeCoffeeAndCookEgg(){
let teapot = new Teapot();
let cup = new Cup();
let pan = new Pan();
let egg = new Egg();
teapot.on().then(teapot.fill.bind(cup));
pan.on()
.then(egg.breake)
.then(egg.fill.bind(cup));
}
Rule #1 - Easy to refactor
Sunrise on Saturnphoto by Cassini probe, JPL
makeCoffeeAndCookEggAfter(){
makeCoffee().then(cookEgg);
}
![Page 37: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/37.jpg)
Long functions: less readable, not reusable, harder to test, harder to refactor
Rule #1 - Do one thing
Sunrise on Saturnphoto by Cassini probe, JPL
![Page 38: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/38.jpg)
Restrict all code to very simple control flow constructs – do not use goto statements and
direct or indirect recursion
Rule #2
Mars, photo by Opportunity mission, JPL
![Page 39: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/39.jpg)
Restrict all code to very simple control flow constructs – do not use goto statements and
direct or indirect recursion
Rule #2 - Predictability
Mars, photo by Opportunity mission, JPL
![Page 40: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/40.jpg)
● If you want to write reliable code – drop to write cool one and write predictable
● Define coding standard and follow it● Use code analyzers to reduce chance for defect:
ESLint + whole lot of plugins, presets● Collect metrics: SonarQube, Plato● Analyze types with Flow/ Closure Tools /
TypeScript
Rule #2 - Predictability
![Page 41: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/41.jpg)
Do not use dynamic memory allocation after initialization
Rule #3
Ceres, photo JPL
![Page 42: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/42.jpg)
GC might become your enemy
Rule #3 - Respect RAM
Ceres, photo JPL
![Page 43: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/43.jpg)
DevTools / Timeline
Measure
Ceres, photo JPL
![Page 44: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/44.jpg)
DevTools / Profile / Take heap snapshot
Compare
Ceres, photo JPL
![Page 45: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/45.jpg)
● Manage your variables with respect. Declare at the top of scope to increase visibility, ESLint vars-on-top. Sort for predictability sort-vars
● Watch for memory leaks, clean listeners and variables when not needed anymore
● ESLint no-unused-vars● Switch JavaScript to static memory allocation
mode via object pooling
Rule #3 - Respect RAM
![Page 46: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/46.jpg)
No new objects in run time.const pool = createObjectsPool(256);
let object = pool.getObject();pool.releaseObject(object);
Object pooling?
Ceres, photo JPL
![Page 47: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/47.jpg)
All loops must have a fixed upper-bound
Rule #4
Sunset at IIS
![Page 48: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/48.jpg)
The assertion density of the code should average to a minimum of two assertions per
function
Rule #5
Jupiter`s eye
![Page 49: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/49.jpg)
The assertion density of the code should average to a minimum of two assertions per
function
Rule #5 - Test well
Jupiter`s eye
![Page 50: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/50.jpg)
● Higher tests density is less defects you get. Minimal amount of tests is 2 per function
● Watch for anomalies in system state during run time. Generate and handle errors in case of critical failures
● Measure coverage but be aware, 100% coverage does not necessarily mean you have well tested code
Rule #5 - Test well
![Page 51: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/51.jpg)
Data objects must be declared at the smallest possible level of scope
Rule #6
City Lights of the Coast of India and the Maldives
![Page 52: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/52.jpg)
Mutable shared state decreases predictability, testability since any part of
system can write there without notyfing the rest
Rule #6 - No shared state
City Lights of the Coast of India and the Maldives
![Page 53: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/53.jpg)
ESLint pureness plugin
Rule #6 - No shared state
City Lights of the Coast of India and the Maldives
![Page 54: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/54.jpg)
The return value of non-void functions must be checked by each calling function, and the
validity of parameters must be checked inside each function
Rule #7
Young stars in NGC 7822
![Page 55: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/55.jpg)
The use of the preprocessor must be limited to the inclusion of header files and simple
macro definitions
Rule #8
On Churyumov–Gerasimenko comet
![Page 56: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/56.jpg)
Nice to know when using transpilers
Performance of ES6 features relative to the ES5
The cost of transpiling ES2015
Falcon9 OG2 launch
![Page 57: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/57.jpg)
The use of pointers should be restricted. Specifically, no more than one level of
dereferencing is allowed. Function pointers are not permitted
Rule #9
Interstellar dust
![Page 58: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/58.jpg)
Dog.body.legs.run();vs
Dog.run();
Rule #9 - LoD
Interstellar dust
![Page 59: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/59.jpg)
Object1.object2.object3.method();vs
const object3 = Object1.object2.object3;object3.method();
Rule #9 - Call chains
Interstellar dust
![Page 60: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/60.jpg)
All code must be compiled, from the first day of development, with all compiler warnings
enabled
Rule #10
MyCn18: An Hourglass Planetary Nebula
![Page 61: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/61.jpg)
All code must be compiled, from the first day of development, with all compiler warnings
enabled
Rule #10 - Keep green
MyCn18: An Hourglass Planetary Nebula
![Page 62: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/62.jpg)
What if we are already fu**ed up?
Rule #10 - If red?
MyCn18: An Hourglass Planetary Nebula
![Page 63: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/63.jpg)
Do not panic.Simply, prioritize,
refactor and add tests piece by piece.
Rule #10 - If red?
MyCn18: An Hourglass Planetary Nebula
![Page 64: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/64.jpg)
Big step for web platform to be perceived as reliable
Small step for developers but...
![Page 65: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/65.jpg)
But still, why not HTML/JS for instruments?
Ok, not that far yet...
Eurofighter maneuvering
![Page 66: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/66.jpg)
But still, why not HTML/JS for instruments?
Ok, not that far yet...
SU-30 take-off
![Page 67: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/67.jpg)
But still, why not HTML/JS for instruments?
Ok, not that far yet...
EFIS displays
![Page 68: Denis Radin - "Applying NASA coding guidelines to JavaScript or airspace is closer than you may think"](https://reader031.vdocument.in/reader031/viewer/2022021923/5a64aa2d7f8b9a88568b502b/html5/thumbnails/68.jpg)
what about ships?
And ...