Slide 1

Slide 1 text

Dealing with dependencies in JavaScript (like a champ !) Radoslav Stankov 31/10/2019

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Radoslav Stankov @rstankov http://rstankov.com http://github.com/rstankov

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

https://speakerdeck.com/rstankov

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

open ./node_modules

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

" JavaScript Fatigue

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

What framework to use? How to manage state? How to fetch data? Which router to use? Which calendar component to use? Which chart component to use?
 ... #

Slide 17

Slide 17 text

Agenda

Slide 18

Slide 18 text

$ Dependency types % Picking dependencies & Handling dependencies

Slide 19

Slide 19 text

Dependency types

Slide 20

Slide 20 text

Medium easy
 to change Big Medium Small Medium Small Small Small Small Small hard to change simple complex * totally unscientific chart '

Slide 21

Slide 21 text

Medium easy
 to change Big Medium Small Medium Small Small Small Small Small hard to change simple complex * totally unscientific chart '

Slide 22

Slide 22 text

What framework to use? How to manage state? How to fetch data? Which router to use? Which calendar component to use? Which chart component to use?
 ... #

Slide 23

Slide 23 text

What framework to use? How to manage state? How to fetch data? Which router to use? Which calendar component to use? Which chart component to use?
 ... #

Slide 24

Slide 24 text

What ecosystem to choose? How to manage state? How to fetch data? Which router to use? Which calendar component use? Which chart component use?
 ... #

Slide 25

Slide 25 text

What ecosystem to choose? How to manage state? How to fetch data? Which router to use? Which calendar component use? Which chart component use?
 ... #

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

History of JS Ecosystem

Slide 28

Slide 28 text

History of JS Ecosystem 2005

Slide 29

Slide 29 text

History of JS Ecosystem 2005 2006

Slide 30

Slide 30 text

History of JS Ecosystem 2005 2010 2006

Slide 31

Slide 31 text

History of JS Ecosystem 2005 2010 2006

Slide 32

Slide 32 text

History of JS Ecosystem 2005 2013 2010 2006

Slide 33

Slide 33 text

History of JS Ecosystem 2005 2019 2013 2010 2006

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

What ecosystem to choose? How to manage state? How to fetch data? Which router to use? Which calendar component use? Which chart component use?
 ... #

Slide 38

Slide 38 text

What ecosystem to choose? How to manage state? How to fetch data? Which router to use? Which calendar component use? Which chart component use?
 ... #

Slide 39

Slide 39 text

Medium easy
 to change Big Medium Small Medium Small Small Small Small Small hard to change simple complex * totally unscientific chart '

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

History of React Ecosystem 2013 2019

Slide 43

Slide 43 text

History of React Ecosystem 2013 2019 2014

Slide 44

Slide 44 text

History of React Ecosystem 2013 2019 2014 2015

Slide 45

Slide 45 text

History of React Ecosystem 2013 2019 2014 2015

Slide 46

Slide 46 text

History of React Ecosystem 2013 2019 2014 2015 2016

Slide 47

Slide 47 text

History of React Ecosystem 2013 2019 2014 2015 2016 Concepts

Slide 48

Slide 48 text

History of React Ecosystem 2013 2019 2014 2015 2016 Libraries

Slide 49

Slide 49 text

History of React Ecosystem 2013 2019 2014 2015 2016

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

What ecosystem to choose? How to manage state? How to fetch data? Which router to use? Which calendar component use? Which chart component use?
 ... #

Slide 53

Slide 53 text

Medium easy
 to change Big Medium Small Medium Small Small Small Small Small hard to change simple complex * totally unscientific chart '

Slide 54

Slide 54 text

Picking Dependencies

Slide 55

Slide 55 text

⏹ Do we really need it? ⏹ Can something we already have do the task we are searching for? ⏹ Can we implement this ourselves? ⏹ Is this properly maintained? ⏹ Is it well documented? ⏹ When was the last version? ⏹ When was the last commit? ⏹ How often does it get a new version? ⏹ Does it have CHANGELOG? ⏹ Were there breaking changes recently? ⏹ Does it have security issues past or present? ⏹ How many dependencies does it come from? ⏹ What the dependency size? ⏹ What is its license? ⏹ Do you use this in any other project? ✅ Questions

Slide 56

Slide 56 text

https://www.npmjs.com/package/lodash

Slide 57

Slide 57 text

https://www.npmjs.com/package/lodash

Slide 58

Slide 58 text

https://www.npmjs.com/package/draft-js

Slide 59

Slide 59 text

https://github.com/facebook/draft-js

Slide 60

Slide 60 text

https://github.com/facebook/draft-js/issues

Slide 61

Slide 61 text

http://npm.broofa.com/?q=draft-js

Slide 62

Slide 62 text

https://bundlephobia.com/result?p=draft-js@0.11.0

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Handling dependencies

Slide 65

Slide 65 text

Who is developer worst enemy?

Slide 66

Slide 66 text

* The designer Who is developer worst enemy?

Slide 67

Slide 67 text

* The designer + The QA Who is developer worst enemy?

Slide 68

Slide 68 text

* The designer + The QA , The sys admin Who is developer worst enemy?

Slide 69

Slide 69 text

* The designer + The QA , The sys admin - The project owner Who is developer worst enemy?

Slide 70

Slide 70 text

* The designer + The QA , The sys admin - The project owner . Santa Who is developer worst enemy?

Slide 71

Slide 71 text

* The designer + The QA , The sys admin - The project owner . Santa / Code coupling Who is developer worst enemy?

Slide 72

Slide 72 text

* The designer + The QA , The sys admin - The project owner . Santa / Code coupling Who is developer worst enemy?

Slide 73

Slide 73 text

/ Code coupling

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

// pages/Home/index.js import * as React from 'react'; import { Jumbotron } from 'react-bootstrap'; import { Link } from 'react-router'; import moment from 'moment'; import styles from './styles.css'; import globalStyles from 'styles/global.css'; import classNames from 'classNames'; import FancyTime from 'fancy-time' export default class Page extends React.Component { state = { time: new Date(), }; componentDidMount() { this.interval = setInterval(this.updateTime, 1000); } componentWillUnmount() { clearInterval(this.interval); this.interval = null; } updateTime = () => { this.setState({ time: new Date() }); } render() { const { time } = this.state.time; return (

Conference

Slide 77

Slide 77 text

export default class Page extends React.Component { state = { time: new Date(), }; componentDidMount() { this.interval = setInterval(this.updateTime, 1000); } componentWillUnmount() { clearInterval(this.interval); this.interval = null; } updateTime = () => { this.setState({ time: new Date() }); } render() { const { time } = this.state.time; return (

Conference

{moment(time).format('HH:mm')} Schedule Venue

); } }

Slide 78

Slide 78 text

Reasons for change

Slide 79

Slide 79 text

Component Dependency Dependency Dependency

Slide 80

Slide 80 text

Component Dependency Dependency Dependency Component Component Dependency Dependency

Slide 81

Slide 81 text

Component Component Component Dependency nent Comp Dependency Dependency Dependency Dependency Dependency Dependency Dep cy

Slide 82

Slide 82 text

Control changes

Slide 83

Slide 83 text

Component Dependency Dependency

Slide 84

Slide 84 text

Component Dependency Dependency Component

Slide 85

Slide 85 text

Component Dependency Dependency Component Component Component

Slide 86

Slide 86 text

Time Moment FancyTime Page Page Page

Slide 87

Slide 87 text

export default class Page extends React.Component { state = { time: new Date(), }; componentDidMount() { this.interval = setInterval(this.updateTime, 1000); } componentWillUnmount() { clearInterval(this.interval); this.interval = null; } updateTime = () => { this.setState({ time: new Date() }); } render() { const { time } = this.state.time; return (

Conference

{moment(time).format('HH:mm')} Schedule Venue

); } }

Slide 88

Slide 88 text

export default class Page extends React.Component { state = { time: new Date(), }; componentDidMount() { this.interval = setInterval(this.updateTime, 1000); } componentWillUnmount() { clearInterval(this.interval); this.interval = null; } updateTime = () => { this.setState({ time: new Date() }); } render() { const { time } = this.state.time; return (

Conference

Schedule Venue

); } }

Slide 89

Slide 89 text

// components/Time/index.js import * as React from 'react'; import classNames from 'classNames'; import styles from './styles.css'; import moment from 'moment'; import FancyTime from 'fancy-time'; export default function Time({ className, time }) { return ( {moment(time).format('HH:mm')} ); }

Slide 90

Slide 90 text

Time Moment FancyTime Page Page Page

Slide 91

Slide 91 text

Time Utils FancyTime Page Page Page Moment

Slide 92

Slide 92 text

// components/Time/index.js import * as React from 'react'; import classNames from 'classNames'; import styles from './styles.css'; import { formatTime } from './utils'; import FancyTime from 'fancy-time'; export default function Time({ className, time }) { return ( {formatTime('clock')} ); } // components/Time/utils.js import moment from 'moment'; const FORMATS = { 'full': null, 'clock': 'HH:mm', }; export function formatTime(time, kind) { const format = FORMATS[kind] return moment(time).format(format); }

Slide 93

Slide 93 text

// pages/Home/index.js import * as React from 'react'; import { Jumbotron } from 'react-bootstrap'; import { Link } from 'react-router'; import styles from './styles.css'; import globalStyles from 'styles/global.css'; import classNames from 'classNames';
 import Time from 'components/Time'; export default class Page extends React.Component { state = { time: new Date(), }; componentDidMount() { this.interval = setInterval(this.updateTime, 1000); } componentWillUnmount() { clearInterval(this.interval); this.interval = null; } updateTime = () => { this.setState({ time: new Date() }); } render() { const { time } = this.state.time; return (

Conference

Slide 94

Slide 94 text

// pages/Home/index.js import * as React from 'react'; import { Jumbotron } from 'react-bootstrap'; import { Link } from 'react-router'; import styles from './styles.css'; import globalStyles from 'styles/global.css'; import classNames from 'classNames'; import Time from 'components/Time'; import Clock from 'components/Clock'; export default class Page extends React.Component { render() { return (

Conference

{(time) => } Schedule Venue

); } }

Slide 95

Slide 95 text

// pages/Home/index.js import * as React from 'react'; import { Jumbotron } from 'react-bootstrap'; import { Link } from 'react-router'; import styles from './styles.css'; import globalStyles from 'styles/global.css'; import classNames from 'classNames'; import Time from 'components/Time'; import Clock from 'components/Clock'; export default class Page extends React.Component { render() { return (

Conference

{(time) => } Schedule Venue

); } }

Slide 96

Slide 96 text

// pages/Home/index.js import * as React from 'react'; import { Link } from 'react-router'; import Time from 'components/Time'; import Clock from 'components/Clock'; import Jumbotron from 'components/Jumbotron'; export default function Page() { return ( {(time) => } Schedule Venue ); }

Slide 97

Slide 97 text

// paths.js export default { schedule() { return '/schedule'; }, venue() { return '/venue'; } };

Slide 98

Slide 98 text

// pages/Home/index.js import * as React from 'react'; import { Link } from 'react-router'; import paths from 'paths'; import Time from 'components/Time'; import Clock from 'components/Clock'; import Jumbotron from 'components/Jumbotron'; export default function Page() { return ( {(time) => } Schedule Venue ); }

Slide 99

Slide 99 text

// pages/Home/index.js import * as React from 'react'; import { Link } from 'react-router'; import paths from 'paths'; import Time from 'components/Time'; import Clock from 'components/Clock'; import Jumbotron from 'components/Jumbotron'; export default function Page() { return ( {(time) => } Schedule Venue ); }

Slide 100

Slide 100 text

// components/Link/index.js import { Link } from 'react-router'; export default function Link({ to, className, children }) { return ( {children} ); }

Slide 101

Slide 101 text

// components/Link/index.js import { Link } from 'found'; export default function Link({ to, className, children }) { return ( {children} ); }

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

Thanks 0

Slide 106

Slide 106 text

https://speakerdeck.com/rstankov