jeremy wells jeremywells [email protected]
TRANSCRIPT
Jeremy Wells
http://blog.postcivilization.comhttp://postcivilization.com
https://twitter.com/jermywellshttps://plus.google.com/+JeremyWells
JAVASCRIPTif (!theFrontier.final()) {theFrontier.current(true);}
(if not the final frontier, the current one)
JAVASCRIPT
•An object based language•Has risen to a primary role in all modern web applications •Is capable of OOP
OBJECT ORIENTED JAVASCRIPT
•No less dynamic than other JS•No less functional than other JS•It’s better organized•It’s more easily managed •It’s more easily maintained•It's more easily unit tested•It’s more modular•etc, etc, etc...
[We all know why OOP is good, right?]
OBJECT ORIENTED JAVASCRIPT
•No classes like C#•A function creates an object
•No access modifiers like C#•Put them out of your mind
[We all know why OOP is good, right?]
What is OOP?
• Inheritance• Encapsulation• Polymorphism• Abstraction
Visit OOP article->
Inheritance-A mechanism for code reuse, serving to establish a hierarchy between objects
Go to Inheritance Fiddle ->
Encapsulation-Restricts access to an object's properties or components.
-Bundles logical units of data/code together with methods intended to operate on that data/code.
Go to Encapsulation Fiddle ->
Polymorphism-An object is also another object.
-Ad Hoc (overloading), Parametric (generics), Subtype (example below).
Go to Polymorphism Fiddle ->
Abstraction-A separation of concepts based upon logical units of implementation.
-Removing non-essential characteristics from something in order to reduce it to a set of essential characteristics
Go to Abstraction Fiddle ->
Scope / Execution Context-Global scope, Function scope, eval code
Scope | Execution Context
Scope and Execution Context are the same thing.
Global ScopeGlobal Scope
Function ScopeFunction ScopeFunction ScopeFunction Scope
Function ScopeFunction Scope
*image from davidshariff.com
Hoisting/Scalar Promotion/Loop Invariant Code Motion-Functions and Variables are automatically moved to the top of their containing scopes/execution contexts.
Hoisting | Scalar Promotion | Loop Invariant Code Motion
1. Variables
2. Functions
•function expressions var foo = function(){ … } (go to fiddle ->)•types as variables var foo = ‘something’; var bar = 1; (go to fiddle ->)
•function declarations function foo (){ … } (go to fiddle ->)
Common Design Patterns-Singleton Pattern
Go to Singleton Fiddle ->
Common Design Patterns-Factory Pattern
Go to Factory Fiddle ->
Common Design Patterns-Fluent Interface / Extension Methods
Go to Fluent Interface / Extension Methods Fiddle ->
Jeremy Wells
http://blog.postcivilization.comhttp://postcivilization.com
https://twitter.com/jermywellshttps://plus.google.com/+JeremyWells
JAVASCRIPTif (!theFrontier.final()) {theFrontier.current(true);}
(if not the final frontier, the current one)