22<!-- attr: { id:'', class:'slide-title', showInPresentation:true, hasScriptWrapper:true } -->
33# JavaScript Patterns
44## Modules and stuff
5- <!-- <img class="slide-image" showInPresentation="true" src="imgs\ pic00.png" style="top:52.89%; left:66.12%; width:36.44%; z-index:-1" /> -->
6- <!-- <img class="slide-image" showInPresentation="true" src="imgs\ pic01.png" style="top:45.54%; left:48.46%; width:26.89%; z-index:-1" /> -->
7- <!-- <img class="slide-image" showInPresentation="true" src="imgs\ pic02.png" style="top:22.07%; left:3.90%; width:27.79%; z-index:-1" /> -->
8- <!-- <img class="slide-image" showInPresentation="true" src="imgs\ pic03.png" style="top:6.25%; left:72.94%; width:23.58%; z-index:-1" /> -->
5+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/ pic00.png" style="top:52.89%; left:66.12%; width:36.44%; z-index:-1" /> -->
6+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/ pic01.png" style="top:45.54%; left:48.46%; width:26.89%; z-index:-1" /> -->
7+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/ pic02.png" style="top:22.07%; left:3.90%; width:27.79%; z-index:-1" /> -->
8+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/ pic03.png" style="top:6.25%; left:72.94%; width:23.58%; z-index:-1" /> -->
99<article class =" signature " >
1010 <p class="signature-course">JavaScript OOP</p>
1111 <p class="signature-initiative">Telerik Software Academy</p>
1818- Module pattern
1919- Revealing module pattern
2020- Singleton pattern
21- <!-- <img class="slide-image" showInPresentation="true" src="imgs\pic04.png" style="top:41.43%; left:51.46%; width:52.89%; z-index:-1" /> -->
22-
23-
21+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/pic04.png" style="top:41.43%; left:51.46%; width:52.89%; z-index:-1" /> -->
2422
2523<!-- section start -->
2624<!-- attr: { id:'', class:'slide-section', showInPresentation:true, hasScriptWrapper:true } -->
2725<!-- # The Module Pattern -->
28- <!-- <img class="slide-image" showInPresentation="true" src="imgs\pic05.png" style="top:45.26%; left:32.91%; width:32.55%; z-index:-1" /> -->
29-
26+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/pic05.png" style="top:45.26%; left:32.91%; width:32.55%; z-index:-1" /> -->
3027
3128<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
3229# The Module Pattern:<br />Pros and Cons
3835 - Not easy to extend
3936 - Some complain about debugging
4037
41-
4238<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
4339# Module Pattern: Structure
4440- Structure:
@@ -85,29 +81,24 @@ controls.getCalculator('First')
8581```
8682
8783<div class =" fragment balloon " style =" top :12% ; left :58% ; width :30% " >The visible members create closures with them</div >
88- <div class =" fragment balloon " style =" top :66% ; left :17% ; width :20% " >Visiable method</div >
89-
84+ <div class =" fragment balloon " style =" top :66% ; left :17% ; width :20% " >Visible method</div >
9085
9186<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
9287# Module Pattern: Summary
9388- Module pattern provides ** encapsulation** of variables and functions
9489- Provides a way to ** add visibility** (public versus private) to members
9590- Each object instance creates new copies of functions in memory
9691
97-
9892<!-- attr: { class:'slide-section demo', showInPresentation:true, hasScriptWrapper:true } -->
9993<!-- # Module Pattern
10094## [Demo]() -->
101- <!-- <img class="slide-image" showInPresentation="true" src="imgs\pic06.png" style="top:45%; left:10.30%; width:26%; z-index:-1" /> -->
102-
103-
95+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/pic06.png" style="top:45%; left:10.30%; width:26%; z-index:-1" /> -->
10496
10597<!-- section start -->
10698<!-- attr: { id:'', class:'slide-section', showInPresentation:true, hasScriptWrapper:true } -->
10799<!-- # The Revealing Module Pattern
108100## Reveal the most interesting members -->
109- <!-- <img class="slide-image" showInPresentation="true" src="imgs\pic07.png" style="top:8.04%; left:76.39%; width:22.92%; z-index:-1" /> -->
110-
101+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/pic07.png" style="top:8.04%; left:76.39%; width:22.92%; z-index:-1" /> -->
111102
112103<!-- attr: { showInPresentation:true, hasScriptWrapper:true, style:'font-size:0.9em' } -->
113104# Revealing Module Pattern:<br />Pros and Cons
@@ -122,7 +113,6 @@ controls.getCalculator('First')
122113 - Some complain about debugging
123114 - Hard to mock hidden objects for testing
124115
125-
126116<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
127117# Revealing Module Pattern: Structure
128118- Structure:
@@ -140,8 +130,6 @@ var module = (function() {
140130}());
141131```
142132
143-
144-
145133<!-- attr: { showInPresentation:true, hasScriptWrapper:true, style:'font-size:0.9em' } -->
146134# Revealing Module Pattern: _ Example_
147135
@@ -170,20 +158,16 @@ controls.getCalculator('First')
170158
171159<div class =" fragment balloon " style =" top :65% ; left :42% ; width :32.89% " >Expose (reveal) only references to hidden member</div >
172160
173-
174161<!-- attr: { showInPresentation:true, hasScriptWrapper:true } -->
175162# Revealing Module Pattern: Summary
176163- Module pattern provides ** encapsulation** of variables and functions
177164- Provides a way to ** add visibility** (public versus private) to members
178165- Extending objects can be difficult
179166
180-
181167<!-- attr: { class:'slide-section demo', showInPresentation:true, hasScriptWrapper:true } -->
182168<!-- # Revealing Module Pattern
183169## [Demo]() -->
184- <!-- <img class="slide-image" showInPresentation="true" src="imgs\pic08.png" style="top:45.63%; left:2%; width:35%; z-index:-1" /> -->
185-
186-
170+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/pic08.png" style="top:45.63%; left:2%; width:35%; z-index:-1" /> -->
187171
188172<!-- section start -->
189173<!-- attr: { class:'slide-section', showInPresentation:true, hasScriptWrapper:true } -->
@@ -208,13 +192,10 @@ var module = module || {}; // if module exists
208192}(module ));
209193```
210194
211-
212-
213195<!-- attr: { class:'slide-section demo', showInPresentation:true, hasScriptWrapper:true } -->
214196<!-- # Augmenting Modules
215197## [Demo]() -->
216- <!-- <img class="slide-image" showInPresentation="true" src="imgs\pic11.png" style="top:45%; left:0%; width:40%; z-index:-1" /> -->
217-
198+ <!-- <img class="slide-image" showInPresentation="true" src="imgs/pic11.png" style="top:45%; left:0%; width:40%; z-index:-1" /> -->
218199
219200<!-- section start -->
220201<!-- attr: { class:'slide-section', showInPresentation:true, hasScriptWrapper:true } -->
@@ -276,7 +257,6 @@ export default function() {} // or 'export default class {}'
276257- More info on [ import] ( https://developer.mozilla.org/en/docs/web/javascript/reference/statements/import )
277258- More info on [ export] ( https://developer.mozilla.org/en/docs/web/javascript/reference/statements/export )
278259
279-
280260# Examples
281261- In the module, we could use the following code
282262``` js
@@ -287,7 +267,7 @@ export function cube(x) {
287267const foo = Math .PI + Math .SQRT2 ;
288268export { cube , foo };
289269```
290- - in another script, we could have
270+ - In another script, we could have
291271``` js
292272import { cube as cb , foo } from ' my-module' ;
293273console .log (cb (3 )); // 27
@@ -300,17 +280,16 @@ console.log(foo); // 4.555806215962888
300280<!-- # Modules and Patterns
301281## Questions? -->
302282
303-
304283<!-- attr: { showInPresentation:true, hasScriptWrapper:true, style:'font-size: 0.9em' } -->
305284# Free Trainings<br />@ Telerik Academy
306285- "Web Design with HTML 5, CSS 3 and JavaScript" course @ Telerik Academy
307286 - [ javascript course] ( http://academy.telerik.com/student-courses/web-design-and-ui/javascript-fundamentals/about )
308- - Telerik Software Academy
309- - [ academy.telerik.com] ( academy.telerik.com )
310- - Telerik Academy @ Facebook
311- - [ facebook.com/TelerikAcademy] ( facebook.com/TelerikAcademy )
312- - Telerik Software Academy Forums
313- - [ forums.academy.telerik.com] ( http://telerikacademy.com/Forum/Home )
287+ - Telerik Software Academy
288+ - [ academy.telerik.com] ( academy.telerik.com )
289+ - Telerik Academy @ Facebook
290+ - [ facebook.com/TelerikAcademy] ( facebook.com/TelerikAcademy )
291+ - Telerik Software Academy Forums
292+ - [ forums.academy.telerik.com] ( http://telerikacademy.com/Forum/Home )
314293
315294<!-- <img class="slide-image" showInPresentation="true" src="imgs/pic16.png" style="top:58.18%; left:90.52%; width:16.97%; z-index:-1" /> -->
316295
0 commit comments