Modular JavaScript

@sander_mak
@pbakker
Modularity
 intro
JavaScript
 pitfalls
JS
 Module
 Systems
Java
 +
 JavaScript
 modularity
y
 M
Wh

ity?
ular
od
Modularity is

key
 
to maintainable code
Modularity 101
Remember
 Java?

Low
 Coupling
High
 Cohesion
Modularity in Java
Bundle B

Bundle A
Imports

+ package org.myapi

+ package org.other.api

- package org.myapi.impl
- package org.util

Imports

Bundle C

+ package org.other.impl
Modularity in Java

OSGi
The
 only
 modularity
 
solution
 for
 Java
 today
Why modularity in JavaScript?
then

now

20%
50%

50%

80%

Java

JavaScript

So...
We
 run
 into
 the
 same
 maintainability
 
problems
 as
 on
 the
 server
 side...
Text

en
 
t
 ev
igh
 it
 m
And
....
orse
e
 w
b
JavaScript Modularity 101

Globals
Anonymous functions
Anonymous
 functions
 prevent
 
putting
 something
 in
 global
 scope

This
 method
 executes,
 but
 is
 not
 
visible
 in