SlideShare a Scribd company logo
Reference architecture GUIDE
marjan@emitknowledge.com
mk.linkedin/marjan.nikolovski
Marjan Nikolovski
A professional senior software engineer and
conference speaker who is mainly hooked on the
.NET platform as development platform and its
derivatives, but from time to time knows to kill
some time with open source software.
Usually spends his time writing systems
backend and testing cutting edge technologies.
In spare time actively participating in holding
technical presentations on conferences and
researching. Specially interested in Distributed
programming, Software architecture,
Middleware, SOA, Non-relational databases and
Workflow driven systems.
 Word-Two;
 JavaScript mistakes from the C# programmer
 Solution structure;
 Solution architecture;
 Product modules;
 UI Components;
 Event Driven Messaging;
 Localization;
 Logging
 Optimizations
 Enterprise JavaScript app - heavy data app that is hard to be maintained;
 Development time increase as the complexity and the codebase grows up;
 Frontend development usually not taken seriously;
 Frontend development always underestimated and without certain
development plan and architecture;
 Writing jQuery still requires knowledge of JavaScript;
 Using global variables and functions;
 Object literal;
 Self-Executing Anonymous Function;
 Revealing Module Pattern;
 Array and object declaration gone bad;
 False value understanding;
 Default value testing;
 Using wrong comparison operators;
 Misusing For..in statement on Arrays;
 Function and Object Scope in JavaScript;
 Not aware of JSLint;
var invalid_username = "Username exists";
function log_in() {
//Placed in global scope when executed
invalid_username = "Really Bad";
}
//Bad way to prevent namespace clashing
function namespace_log_out() {
}
//Functions
window.log_in();
window.namespace_log_out();
//Global variables are available off window object
console.log(window.invalid_username);
console.log(window.log_in);
console.log(window.namespace_log_out);
 Similar to JSON syntax;
 Provide properties and function by choice;
 Everything defined in the object literal is public;
Pros Cons
Remove global namespaces to properties,
variables and methods
Difficult to maintain and understand
Functionality can be added at a later
point
No way to have private properties and/or
methods
All properties and methods are public
//Object Literal declaring
properties and methods
var user_model = {
//public property
username: "Some user",
//public method
login: function() {}
};
 Non name function that executes after it is defined;
 Isolate variables and functions from global namespace;
//Self-Executing Anonymous
Function:
(function() {
//private variable
var username = "Some username";
//private function
function login() {}
login();
}());
Pros Cons
Hide implementation
from external code
All information is
hidden
The code runs only
once
Complicated on first
sight
Not using object literal
notation
 Uses the concept of the Self-Executing Anonymous Function;
 Store the result into a variable;
//Revealing Module Pattern (Public & Private)
var user_proxy = (function() {
var me = {},
//Private property
username = "Some username";
//Public property
me.message = "A message";
//Public method
me.Login = function() {
pvtLogin();
};
//Private method
function pvtLogin() {
//Do something...
}
//Return just the public parts
return me;
}());
Pros Cons
Allow private and
public properties and
methods
Easy to understand
 Many ways to create an object, but only one is the correct one;
 Hesitate the temptation to use the new keyword;
// bad practice
var user = new Object();
// good practice
var user = {};
// bad practice
function User(uname){
this.username = uname;
}
var user = new User(‘test’);
user.username == ‘test’
var user = User(‘test’);
user.username != ‘test’
user.username == window.
username
 Same goes for arrays. Many ways to create an array, but only one is
the correct one;
// bad practice
var userList = new Array(10);
userList[0] === undefined;
userList.length == 10;
// good practice
var userList = [];
C#
If(user != null && user.Length > 0)
{
// do something
}
JavaScript
If(user)
{
// do something
}
OR
user = user || ‘default value’;
 JavaScript ninja behavior can sometimes gives us unexpected
results;
 Sometime value comparison is not what it looks like;
 Always use === or !== when doing comparison in JavaScript;
// Unexpected comparisons
0 == '‘ //true
0 == ‘0’ //true
false == '0‘ //true
null == undefined //true
' trn ' == 0 //true
0 === '' //false
0 === '0' //false
false === '0' //false
null === undefined //false
' trn ' === 0 //false
 Does not guarantee the order of the items that are going to be
retrieved by the iterator;
 The iterator can iterate both array and objects;
 Bad declaration can result in incorrect iterator execution;
var user = {
username: ‘Test’,
name:’Some name’
};
for(var data in user){
alert(data);
}
// outputs
username, name
var userArray = [];
userArray.push(‘data’)
userArray.name = ‘Test’;
for(var data in user){
alert(data);
alert(user[data]);
}
// outputs 0, name
// outputs data, Test
 Variable scope visible in the
function;
 All internal closures or
functions will see the defined
variables in the parent
function scope;
function login() {
var user = "test",
isWrongCaptcha = true;
if (isWrongCaptcha) {
var timeToWait = 10;
console.log( "Waiting " + timeToWait + " minutes" );
internal_log_in();
}
function internal_log_in() {
//The chew function also has access to the
//timeToWait variable because it is part of the
//eat function's scope
console.log("After waiting " + timeToWait +
" minutes, " + "I am going to login to the system");
}
}
login();
//Waiting 10 minutes
//After waiting 10 minutes, I am going to login to the
system
 JSLint is a static code analysis tool used in software development for
checking if JavaScript source code complies with coding rules;
 Provided primarily as an online tool, but there are also command-line
adaptations;
 Large scale JavaScript development involves different source types and
formats;
 Presentation code;
 Proxy code;
 Third party libs;
 Solution structure is tightly coupled with the solution architecture approach;
 Physical structure should match the solution architecture abstraction;
 /scripts
 /utils
 /controllers
 /models
 /modules
 /bootstrappers
 /libs
 /components
 /external
 /content
 /images
 /css
 /media
 /scripts
 Development helpers
 Proxy classes to the server methods
 Models used for the client and server side
 Modules per functionality
 Application/module/plugin initializers
 /libs
 Custom developed components
 External libraries
 /content
 /images
 /css
 /media
 Plan before execute;
 Questions to be answered before the design:
 What will be reused?
 How many modules depend on other modules?
 Are your module sandboxed?
 Break your application into small single-purpose parts - modules;
 Module pattern gives you implementation privacy, state and code
organization;
 Provide a way to handle private and public methods and variables;
 Protects the code to leak into the global namespace;
namespace.modulename = function(module) {
var privateVar = 'some data';
module.init = function(){
};
module.doSomething = function(){
internalDoSomething();
};
function internalDoSomething(){
};
return module;
}(namespace.modulename || {});
 In some point there will be a need to establish module communication;
 In order to avoid tight coupling we can utilize the mediator pattern;
 The mediator pattern encapsulates how a set of modules interact;
 Utilized via Pub/Sub;
 Modules communicates via message publishing;
;(function ($) {
var o = $({});
$.subscribe = function () {
o.on.apply(o, arguments);
};
$.unsubscribe = function () {
o.off.apply(o, arguments);
};
$.publish = function () {
o.trigger.apply(o, arguments);
};
} (jQuery));
$.subscribe('namespace/action',
function (data) {
alert(data);
});
$.publish('namespace/action',
'data')
 Wrapping it all together;
 The modules publish events which inform the application that
something is happening;
 The modules in the system are subscribed to certain events;
 The mediator enables the modules to communicate via the PubSub
mechanism;
 Utilizing the module pattern;
 JavaScript coding pattern;
 Module pattern implementation with anonymous closures;
 Should be considered:
 Every module should be part of a namespace;
 Every module can contains sub modules;
 What will be the global import of the module;
 What will the module export;
var namespace.module = (function (import) {
var me = {};
// private property
var somePrivateVar = 'Test data';
// public property
me.publicProperty = 'Public data';
// private method
function privateMethod() {
somePrivateVar = 'executed pvt method';
}
// publicmethod
me.publicMethod = function () {
return me.publicProperty;
};
// the module export
return me;
}(GLOBAL_IMPORT));
 Module inheritance can be done with module import;
namespace.module = (function (baseModule) {
var me = {};
// inherit the methods and properties
for (key in baseModule) {
if (baseModule.hasOwnProperty(key)) {
me[key] = baseModule[key];
}
}
var base_publicMethod = baseModule.publicMethod;
// public method override
me.publicMethod = function () {
return base_publicMethod();
};
// the module export
return me;
}(module));
 Build your UI components in jQuery plugin fashion;
 jQuery plugin pattern is well known and understood by most of the UI
developers;
 Offers simple implementation syntax and offers extensibility;
$.fn.pluginName = function(options)
{
// Create some defaults, extending them with any options that were provided
var settings = $.extend( {
'location' : 'top',
'background-color' : 'blue'
}, options);
// return the object back to the chained call flow
return this.each(function() // This is the main processor
// function that executes on
// each selected element
// (e.g: jQuery("div"))
{
var $this = $(this);
alert($this);
});
};
})(jQuery);
// usage
$(document).ready(function() {
// create a new instance of the plugin
$(‘selector’).pluginName(options);
});
 Allow communication between modules via event publishing managed by
pub/sub component;
 Each module can publish events, subscribe and unsubscribe to events;
app.usermodule = (function () {
var me = {};
me.onNewFriendNotificaion =
function(notification){
alert(notification.from);
};
me.init = function(){
$.subscribe('on-new-friend-
notificaion', me.onNewFriendNotificaion);
};
me.destroy = function(){
$.unsubscribe('on-new-
friend-notificaion', me.onNewFriendNotificaion);
};
return me;
}());
app.streammodule = (function () {
var me = {};
me.post = function(){
// do some client logic and
notify the other modules
$.publish('on-new-friend-
notificaion', { from:'user' });
};
return me;
}());
 String localization;
 Dates, times, numbers, and currencies;
 Use jQuery Globalize plugin for Dates, times, numbers, and currencies;
 Store string resources in JSON format so they would be native to client;
 Server string resources per culture;
 Build language manager for the string resources;
 Load the JSON resources into the language manager;
 User the language manager to translate plugins, DOM elements and strings;
 Useful for tracking modules state, variables and processes while in
development;
 Natively supported in all of the new modern browsers;
 Use an existing logging framework or wrap your logger around the existing
browsers logger;
var logger = function(){
var logger = {};
window.onerror = function(message, file, line) {
logError(file + ':' + line + 'nn' + message);
};
logger.log = function(message){
logError(message);
};
function logError(message){
if(console && console.log){
console.log(message);
}
};
return logger;
}();
 Add style sheets in the HEAD
 Add scripts at the bottom of the <BODY>
 Add favicon
 Create CSS sprites
 Enable GZIP and static resource Caching
 Minimize CSS and JavaScript files
 Set cookie less domain for static resources
 routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
 Put all of your icons and assets that you are using for your design into one
file. Create CSS file to access the resources. You will minimize n*request per
resource time that the browser would call for the separate assets.
 Check out Sprite cow – http://www.spritecow.com
<system.webServer>
<staticContent>
<remove fileExtension=".js" />
<remove fileExtension=".css" />
<mimeMap fileExtension=".js" mimeType="text/javascript" />
<mimeMap fileExtension=".css" mimeType="text/css" />
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge"
cacheControlMaxAge="500.00:00:00" />
</staticContent>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>
@(Bundle.Css()
.Add("~/Content/base.css")
.Add("~/Content/CSS/Plugins/BootstrapDatepicker/daterangepicker-bs3.css")
.MvcRender("~/Content/CSS/min/combined_#.css"))
------------------------
@(Bundle.JavaScript()
.Add(@"~/Scripts/lib/jquery-2.0.2.min.js")
.Add(@"~/Scripts/lib/jquery.slimscroll.min.js")
.Add(@"~/Scripts/lib/jquery-ui-1.10.3.custom.min.js")
.Add(@"~/Scripts/lib/typeahead.min.js")
.Add(@"~/Scripts/lib/daterangepicker.js")
.Add(@"~/Scripts/lib/moment.min.js")
.MvcRender("~/Scripts/min/combined_#.js"))
 Go to your domain hosting account and set a subdomain that point to your
web application
 Set your static resources to point to the subdomain to avoid cookie data
transfer
Built to last   javascript for enterprise

More Related Content

What's hot

A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
Jim Driscoll
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
Guy Nir
 
JavaFX programming
JavaFX programmingJavaFX programming
JavaFX programming
Fulvio Corno
 
Struts2 course chapter 1: Evolution of Web Applications
Struts2 course chapter 1: Evolution of Web ApplicationsStruts2 course chapter 1: Evolution of Web Applications
Struts2 course chapter 1: Evolution of Web Applications
JavaEE Trainers
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
Andy Schwartz
 
Design Patterns in iOS
Design Patterns in iOSDesign Patterns in iOS
Design Patterns in iOS
Yi-Shou Chen
 
Building a JavaScript Module Framework at Gilt
Building a JavaScript Module Framework at GiltBuilding a JavaScript Module Framework at Gilt
Building a JavaScript Module Framework at Gilt
Eric Shepherd
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
Guy Nir
 
Jsf intro
Jsf introJsf intro
Jsf intro
vantinhkhuc
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
zeeshanhanif
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
BG Java EE Course
 
Building a Web-bridge for JADE agents
Building a Web-bridge for JADE agentsBuilding a Web-bridge for JADE agents
Building a Web-bridge for JADE agents
infopapers
 
Java server faces
Java server facesJava server faces
Java server faces
Fábio Santos
 
Ten Minutes To Tellurium
Ten Minutes To TelluriumTen Minutes To Tellurium
Ten Minutes To Tellurium
John.Jian.Fang
 
Manageable Robust Automated Ui Test
Manageable Robust Automated Ui TestManageable Robust Automated Ui Test
Manageable Robust Automated Ui Test
John.Jian.Fang
 
TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6
Lokesh Singrol
 
Java Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component TutorialJava Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component Tutorial
Sagun Dhakhwa
 
Jsf presentation
Jsf presentationJsf presentation
Jsf presentation
Ashish Gupta
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
guest764934
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
People Strategists
 

What's hot (20)

A Complete Tour of JSF 2
A Complete Tour of JSF 2A Complete Tour of JSF 2
A Complete Tour of JSF 2
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
JavaFX programming
JavaFX programmingJavaFX programming
JavaFX programming
 
Struts2 course chapter 1: Evolution of Web Applications
Struts2 course chapter 1: Evolution of Web ApplicationsStruts2 course chapter 1: Evolution of Web Applications
Struts2 course chapter 1: Evolution of Web Applications
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
Design Patterns in iOS
Design Patterns in iOSDesign Patterns in iOS
Design Patterns in iOS
 
Building a JavaScript Module Framework at Gilt
Building a JavaScript Module Framework at GiltBuilding a JavaScript Module Framework at Gilt
Building a JavaScript Module Framework at Gilt
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
Building a Web-bridge for JADE agents
Building a Web-bridge for JADE agentsBuilding a Web-bridge for JADE agents
Building a Web-bridge for JADE agents
 
Java server faces
Java server facesJava server faces
Java server faces
 
Ten Minutes To Tellurium
Ten Minutes To TelluriumTen Minutes To Tellurium
Ten Minutes To Tellurium
 
Manageable Robust Automated Ui Test
Manageable Robust Automated Ui TestManageable Robust Automated Ui Test
Manageable Robust Automated Ui Test
 
TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6TY.BSc.IT Java QB U6
TY.BSc.IT Java QB U6
 
Java Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component TutorialJava Swing Custom GUI MVC Component Tutorial
Java Swing Custom GUI MVC Component Tutorial
 
Jsf presentation
Jsf presentationJsf presentation
Jsf presentation
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
 

Viewers also liked

Microscopic details
Microscopic detailsMicroscopic details
Microscopic details
ibfrostybrew
 
Digitalgiftfor brad
Digitalgiftfor bradDigitalgiftfor brad
Digitalgiftfor brad
cmniehaus
 
Perpika dan Pak RT
Perpika dan Pak RTPerpika dan Pak RT
Perpika dan Pak RT
Hani Nelly Sukma
 
Perpika dan Pak RT
Perpika dan Pak RTPerpika dan Pak RT
Perpika dan Pak RT
Hani Nelly Sukma
 
Phoenix Caribbean
Phoenix CaribbeanPhoenix Caribbean
Phoenix Caribbean
Guy Phoenix
 
Anti Corruption Layers
Anti Corruption LayersAnti Corruption Layers
Anti Corruption Layers
Marjan Nikolovski
 
Crusell Bridge
Crusell BridgeCrusell Bridge
Crusell Bridge
Hani Nelly Sukma
 
Phoenix Caribbean
Phoenix CaribbeanPhoenix Caribbean
Phoenix Caribbean
Guy Phoenix
 
The enlargement of EU by acceeding new countries
The enlargement of EU by acceeding new countriesThe enlargement of EU by acceeding new countries
The enlargement of EU by acceeding new countries
Vitor Santos
 
Observations on dag scheduling and dynamic load-balancing using genetic algor...
Observations on dag scheduling and dynamic load-balancing using genetic algor...Observations on dag scheduling and dynamic load-balancing using genetic algor...
Observations on dag scheduling and dynamic load-balancing using genetic algor...
Rahul Jain
 
Consumer finance by Ahmed Baig
Consumer finance by Ahmed BaigConsumer finance by Ahmed Baig
Consumer finance by Ahmed Baig
Ahmedbaigmirza
 
Risk Assessment of Construction Projects Using Network Based Adaptive Fuzzy S...
Risk Assessment of Construction Projects Using Network Based Adaptive Fuzzy S...Risk Assessment of Construction Projects Using Network Based Adaptive Fuzzy S...
Risk Assessment of Construction Projects Using Network Based Adaptive Fuzzy S...
Hani Nelly Sukma
 
Competition and oligopoly in telecommunications industry in the EU
Competition and oligopoly in telecommunications industry in the EUCompetition and oligopoly in telecommunications industry in the EU
Competition and oligopoly in telecommunications industry in the EU
Vitor Santos
 
포키비언_카루라이브_플랫폼_협업제안서_v3.2_public
포키비언_카루라이브_플랫폼_협업제안서_v3.2_public포키비언_카루라이브_플랫폼_협업제안서_v3.2_public
포키비언_카루라이브_플랫폼_협업제안서_v3.2_public
Dong-il Chang
 
Elizabethan Theatre Project
Elizabethan Theatre ProjectElizabethan Theatre Project
Elizabethan Theatre Project
Paula-Valentina Dozsa
 
카루라이브 커넥티드카 서비스 플랫폼 소개 v2.4
카루라이브 커넥티드카 서비스 플랫폼 소개 v2.4카루라이브 커넥티드카 서비스 플랫폼 소개 v2.4
카루라이브 커넥티드카 서비스 플랫폼 소개 v2.4
Dong-il Chang
 
indONEsia - PNU we are one festival 2011
indONEsia - PNU we are one festival 2011indONEsia - PNU we are one festival 2011
indONEsia - PNU we are one festival 2011
Hani Nelly Sukma
 
Pokevian connected car_products_v3.0.0
Pokevian connected car_products_v3.0.0Pokevian connected car_products_v3.0.0
Pokevian connected car_products_v3.0.0
Dong-il Chang
 

Viewers also liked (18)

Microscopic details
Microscopic detailsMicroscopic details
Microscopic details
 
Digitalgiftfor brad
Digitalgiftfor bradDigitalgiftfor brad
Digitalgiftfor brad
 
Perpika dan Pak RT
Perpika dan Pak RTPerpika dan Pak RT
Perpika dan Pak RT
 
Perpika dan Pak RT
Perpika dan Pak RTPerpika dan Pak RT
Perpika dan Pak RT
 
Phoenix Caribbean
Phoenix CaribbeanPhoenix Caribbean
Phoenix Caribbean
 
Anti Corruption Layers
Anti Corruption LayersAnti Corruption Layers
Anti Corruption Layers
 
Crusell Bridge
Crusell BridgeCrusell Bridge
Crusell Bridge
 
Phoenix Caribbean
Phoenix CaribbeanPhoenix Caribbean
Phoenix Caribbean
 
The enlargement of EU by acceeding new countries
The enlargement of EU by acceeding new countriesThe enlargement of EU by acceeding new countries
The enlargement of EU by acceeding new countries
 
Observations on dag scheduling and dynamic load-balancing using genetic algor...
Observations on dag scheduling and dynamic load-balancing using genetic algor...Observations on dag scheduling and dynamic load-balancing using genetic algor...
Observations on dag scheduling and dynamic load-balancing using genetic algor...
 
Consumer finance by Ahmed Baig
Consumer finance by Ahmed BaigConsumer finance by Ahmed Baig
Consumer finance by Ahmed Baig
 
Risk Assessment of Construction Projects Using Network Based Adaptive Fuzzy S...
Risk Assessment of Construction Projects Using Network Based Adaptive Fuzzy S...Risk Assessment of Construction Projects Using Network Based Adaptive Fuzzy S...
Risk Assessment of Construction Projects Using Network Based Adaptive Fuzzy S...
 
Competition and oligopoly in telecommunications industry in the EU
Competition and oligopoly in telecommunications industry in the EUCompetition and oligopoly in telecommunications industry in the EU
Competition and oligopoly in telecommunications industry in the EU
 
포키비언_카루라이브_플랫폼_협업제안서_v3.2_public
포키비언_카루라이브_플랫폼_협업제안서_v3.2_public포키비언_카루라이브_플랫폼_협업제안서_v3.2_public
포키비언_카루라이브_플랫폼_협업제안서_v3.2_public
 
Elizabethan Theatre Project
Elizabethan Theatre ProjectElizabethan Theatre Project
Elizabethan Theatre Project
 
카루라이브 커넥티드카 서비스 플랫폼 소개 v2.4
카루라이브 커넥티드카 서비스 플랫폼 소개 v2.4카루라이브 커넥티드카 서비스 플랫폼 소개 v2.4
카루라이브 커넥티드카 서비스 플랫폼 소개 v2.4
 
indONEsia - PNU we are one festival 2011
indONEsia - PNU we are one festival 2011indONEsia - PNU we are one festival 2011
indONEsia - PNU we are one festival 2011
 
Pokevian connected car_products_v3.0.0
Pokevian connected car_products_v3.0.0Pokevian connected car_products_v3.0.0
Pokevian connected car_products_v3.0.0
 

Similar to Built to last javascript for enterprise

SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
SMIJava
 
RequireJS
RequireJSRequireJS
RequireJS
Tim Doherty
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
ciklum_ods
 
Dive into Play Framework
Dive into Play FrameworkDive into Play Framework
Dive into Play Framework
Maher Gamal
 
Java programming concept
Java programming conceptJava programming concept
Java programming concept
Sanjay Gunjal
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Iakiv Kramarenko
 
Struts 1
Struts 1Struts 1
Struts 1
Lalit Garg
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
DivyanshGupta922023
 
Modular javascript
Modular javascriptModular javascript
Modular javascript
Zain Shaikh
 
Javascript for the c# developer
Javascript for the c# developerJavascript for the c# developer
Javascript for the c# developer
Salvatore Fazio
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
Seb Rose
 
Spring boot
Spring bootSpring boot
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna Upreti
 
CAR SHOWROOM SYSTEM
CAR SHOWROOM SYSTEMCAR SHOWROOM SYSTEM
CAR SHOWROOM SYSTEM
Abhishek Shakya
 
Java script best practices v4
Java script best practices v4Java script best practices v4
Java script best practices v4
Thor Jørund Nydal
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalCampDN
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
Alex S
 
Testable JavaScript: Application Architecture
Testable JavaScript:  Application ArchitectureTestable JavaScript:  Application Architecture
Testable JavaScript: Application Architecture
Mark Trostler
 

Similar to Built to last javascript for enterprise (20)

SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
RequireJS
RequireJSRequireJS
RequireJS
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Dive into Play Framework
Dive into Play FrameworkDive into Play Framework
Dive into Play Framework
 
Java programming concept
Java programming conceptJava programming concept
Java programming concept
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
 
Struts 1
Struts 1Struts 1
Struts 1
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
 
Modular javascript
Modular javascriptModular javascript
Modular javascript
 
Javascript for the c# developer
Javascript for the c# developerJavascript for the c# developer
Javascript for the c# developer
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Spring boot
Spring bootSpring boot
Spring boot
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
CAR SHOWROOM SYSTEM
CAR SHOWROOM SYSTEMCAR SHOWROOM SYSTEM
CAR SHOWROOM SYSTEM
 
Java script best practices v4
Java script best practices v4Java script best practices v4
Java script best practices v4
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
Testable JavaScript: Application Architecture
Testable JavaScript:  Application ArchitectureTestable JavaScript:  Application Architecture
Testable JavaScript: Application Architecture
 

More from Marjan Nikolovski

Marjan.nikolovski down the rabbit hole error handling examined-v01
Marjan.nikolovski down the rabbit hole   error handling examined-v01Marjan.nikolovski down the rabbit hole   error handling examined-v01
Marjan.nikolovski down the rabbit hole error handling examined-v01
Marjan Nikolovski
 
Down the rabbit hole - Error handling examined
Down the rabbit hole - Error handling examinedDown the rabbit hole - Error handling examined
Down the rabbit hole - Error handling examined
Marjan Nikolovski
 
Enterprise js pratices
Enterprise js praticesEnterprise js pratices
Enterprise js pratices
Marjan Nikolovski
 
Skyrocketing to the cloud with Windows Azure
Skyrocketing to the cloud with Windows AzureSkyrocketing to the cloud with Windows Azure
Skyrocketing to the cloud with Windows AzureMarjan Nikolovski
 
Band of brothers, building scalable social web apps on windows azure with asp...
Band of brothers, building scalable social web apps on windows azure with asp...Band of brothers, building scalable social web apps on windows azure with asp...
Band of brothers, building scalable social web apps on windows azure with asp...
Marjan Nikolovski
 
Yellow.4 marjan nikolovski hunting rabbits and event-driven programming
Yellow.4 marjan nikolovski hunting rabbits and event-driven programmingYellow.4 marjan nikolovski hunting rabbits and event-driven programming
Yellow.4 marjan nikolovski hunting rabbits and event-driven programming
Marjan Nikolovski
 
No sql - { If and Else }
No sql - { If and Else }No sql - { If and Else }
No sql - { If and Else }
Marjan Nikolovski
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
Marjan Nikolovski
 

More from Marjan Nikolovski (9)

Marjan.nikolovski down the rabbit hole error handling examined-v01
Marjan.nikolovski down the rabbit hole   error handling examined-v01Marjan.nikolovski down the rabbit hole   error handling examined-v01
Marjan.nikolovski down the rabbit hole error handling examined-v01
 
Down the rabbit hole - Error handling examined
Down the rabbit hole - Error handling examinedDown the rabbit hole - Error handling examined
Down the rabbit hole - Error handling examined
 
Enterprise js pratices
Enterprise js praticesEnterprise js pratices
Enterprise js pratices
 
Skyrocketing to the cloud with Windows Azure
Skyrocketing to the cloud with Windows AzureSkyrocketing to the cloud with Windows Azure
Skyrocketing to the cloud with Windows Azure
 
Band of brothers, building scalable social web apps on windows azure with asp...
Band of brothers, building scalable social web apps on windows azure with asp...Band of brothers, building scalable social web apps on windows azure with asp...
Band of brothers, building scalable social web apps on windows azure with asp...
 
Yellow.4 marjan nikolovski hunting rabbits and event-driven programming
Yellow.4 marjan nikolovski hunting rabbits and event-driven programmingYellow.4 marjan nikolovski hunting rabbits and event-driven programming
Yellow.4 marjan nikolovski hunting rabbits and event-driven programming
 
No sql - { If and Else }
No sql - { If and Else }No sql - { If and Else }
No sql - { If and Else }
 
High Performance Computing
High Performance ComputingHigh Performance Computing
High Performance Computing
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 

Recently uploaded

UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 

Recently uploaded (20)

UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 

Built to last javascript for enterprise

  • 2. marjan@emitknowledge.com mk.linkedin/marjan.nikolovski Marjan Nikolovski A professional senior software engineer and conference speaker who is mainly hooked on the .NET platform as development platform and its derivatives, but from time to time knows to kill some time with open source software. Usually spends his time writing systems backend and testing cutting edge technologies. In spare time actively participating in holding technical presentations on conferences and researching. Specially interested in Distributed programming, Software architecture, Middleware, SOA, Non-relational databases and Workflow driven systems.
  • 3.  Word-Two;  JavaScript mistakes from the C# programmer  Solution structure;  Solution architecture;  Product modules;  UI Components;  Event Driven Messaging;  Localization;  Logging  Optimizations
  • 4.  Enterprise JavaScript app - heavy data app that is hard to be maintained;  Development time increase as the complexity and the codebase grows up;  Frontend development usually not taken seriously;  Frontend development always underestimated and without certain development plan and architecture;
  • 5.  Writing jQuery still requires knowledge of JavaScript;  Using global variables and functions;  Object literal;  Self-Executing Anonymous Function;  Revealing Module Pattern;  Array and object declaration gone bad;  False value understanding;  Default value testing;  Using wrong comparison operators;  Misusing For..in statement on Arrays;  Function and Object Scope in JavaScript;  Not aware of JSLint;
  • 6. var invalid_username = "Username exists"; function log_in() { //Placed in global scope when executed invalid_username = "Really Bad"; } //Bad way to prevent namespace clashing function namespace_log_out() { } //Functions window.log_in(); window.namespace_log_out(); //Global variables are available off window object console.log(window.invalid_username); console.log(window.log_in); console.log(window.namespace_log_out);
  • 7.  Similar to JSON syntax;  Provide properties and function by choice;  Everything defined in the object literal is public; Pros Cons Remove global namespaces to properties, variables and methods Difficult to maintain and understand Functionality can be added at a later point No way to have private properties and/or methods All properties and methods are public //Object Literal declaring properties and methods var user_model = { //public property username: "Some user", //public method login: function() {} };
  • 8.  Non name function that executes after it is defined;  Isolate variables and functions from global namespace; //Self-Executing Anonymous Function: (function() { //private variable var username = "Some username"; //private function function login() {} login(); }()); Pros Cons Hide implementation from external code All information is hidden The code runs only once Complicated on first sight Not using object literal notation
  • 9.  Uses the concept of the Self-Executing Anonymous Function;  Store the result into a variable; //Revealing Module Pattern (Public & Private) var user_proxy = (function() { var me = {}, //Private property username = "Some username"; //Public property me.message = "A message"; //Public method me.Login = function() { pvtLogin(); }; //Private method function pvtLogin() { //Do something... } //Return just the public parts return me; }()); Pros Cons Allow private and public properties and methods Easy to understand
  • 10.  Many ways to create an object, but only one is the correct one;  Hesitate the temptation to use the new keyword; // bad practice var user = new Object(); // good practice var user = {}; // bad practice function User(uname){ this.username = uname; } var user = new User(‘test’); user.username == ‘test’ var user = User(‘test’); user.username != ‘test’ user.username == window. username
  • 11.  Same goes for arrays. Many ways to create an array, but only one is the correct one; // bad practice var userList = new Array(10); userList[0] === undefined; userList.length == 10; // good practice var userList = [];
  • 12. C# If(user != null && user.Length > 0) { // do something } JavaScript If(user) { // do something } OR user = user || ‘default value’;
  • 13.  JavaScript ninja behavior can sometimes gives us unexpected results;  Sometime value comparison is not what it looks like;  Always use === or !== when doing comparison in JavaScript; // Unexpected comparisons 0 == '‘ //true 0 == ‘0’ //true false == '0‘ //true null == undefined //true ' trn ' == 0 //true 0 === '' //false 0 === '0' //false false === '0' //false null === undefined //false ' trn ' === 0 //false
  • 14.  Does not guarantee the order of the items that are going to be retrieved by the iterator;  The iterator can iterate both array and objects;  Bad declaration can result in incorrect iterator execution; var user = { username: ‘Test’, name:’Some name’ }; for(var data in user){ alert(data); } // outputs username, name var userArray = []; userArray.push(‘data’) userArray.name = ‘Test’; for(var data in user){ alert(data); alert(user[data]); } // outputs 0, name // outputs data, Test
  • 15.  Variable scope visible in the function;  All internal closures or functions will see the defined variables in the parent function scope; function login() { var user = "test", isWrongCaptcha = true; if (isWrongCaptcha) { var timeToWait = 10; console.log( "Waiting " + timeToWait + " minutes" ); internal_log_in(); } function internal_log_in() { //The chew function also has access to the //timeToWait variable because it is part of the //eat function's scope console.log("After waiting " + timeToWait + " minutes, " + "I am going to login to the system"); } } login(); //Waiting 10 minutes //After waiting 10 minutes, I am going to login to the system
  • 16.  JSLint is a static code analysis tool used in software development for checking if JavaScript source code complies with coding rules;  Provided primarily as an online tool, but there are also command-line adaptations;
  • 17.  Large scale JavaScript development involves different source types and formats;  Presentation code;  Proxy code;  Third party libs;  Solution structure is tightly coupled with the solution architecture approach;  Physical structure should match the solution architecture abstraction;
  • 18.  /scripts  /utils  /controllers  /models  /modules  /bootstrappers  /libs  /components  /external  /content  /images  /css  /media  /scripts  Development helpers  Proxy classes to the server methods  Models used for the client and server side  Modules per functionality  Application/module/plugin initializers  /libs  Custom developed components  External libraries  /content  /images  /css  /media
  • 19.  Plan before execute;  Questions to be answered before the design:  What will be reused?  How many modules depend on other modules?  Are your module sandboxed?
  • 20.  Break your application into small single-purpose parts - modules;  Module pattern gives you implementation privacy, state and code organization;  Provide a way to handle private and public methods and variables;  Protects the code to leak into the global namespace;
  • 21. namespace.modulename = function(module) { var privateVar = 'some data'; module.init = function(){ }; module.doSomething = function(){ internalDoSomething(); }; function internalDoSomething(){ }; return module; }(namespace.modulename || {});
  • 22.  In some point there will be a need to establish module communication;  In order to avoid tight coupling we can utilize the mediator pattern;  The mediator pattern encapsulates how a set of modules interact;
  • 23.
  • 24.  Utilized via Pub/Sub;  Modules communicates via message publishing; ;(function ($) { var o = $({}); $.subscribe = function () { o.on.apply(o, arguments); }; $.unsubscribe = function () { o.off.apply(o, arguments); }; $.publish = function () { o.trigger.apply(o, arguments); }; } (jQuery)); $.subscribe('namespace/action', function (data) { alert(data); }); $.publish('namespace/action', 'data')
  • 25.  Wrapping it all together;  The modules publish events which inform the application that something is happening;  The modules in the system are subscribed to certain events;  The mediator enables the modules to communicate via the PubSub mechanism;
  • 26.
  • 27.  Utilizing the module pattern;  JavaScript coding pattern;  Module pattern implementation with anonymous closures;  Should be considered:  Every module should be part of a namespace;  Every module can contains sub modules;  What will be the global import of the module;  What will the module export;
  • 28. var namespace.module = (function (import) { var me = {}; // private property var somePrivateVar = 'Test data'; // public property me.publicProperty = 'Public data'; // private method function privateMethod() { somePrivateVar = 'executed pvt method'; } // publicmethod me.publicMethod = function () { return me.publicProperty; }; // the module export return me; }(GLOBAL_IMPORT));
  • 29.  Module inheritance can be done with module import; namespace.module = (function (baseModule) { var me = {}; // inherit the methods and properties for (key in baseModule) { if (baseModule.hasOwnProperty(key)) { me[key] = baseModule[key]; } } var base_publicMethod = baseModule.publicMethod; // public method override me.publicMethod = function () { return base_publicMethod(); }; // the module export return me; }(module));
  • 30.  Build your UI components in jQuery plugin fashion;  jQuery plugin pattern is well known and understood by most of the UI developers;  Offers simple implementation syntax and offers extensibility;
  • 31. $.fn.pluginName = function(options) { // Create some defaults, extending them with any options that were provided var settings = $.extend( { 'location' : 'top', 'background-color' : 'blue' }, options); // return the object back to the chained call flow return this.each(function() // This is the main processor // function that executes on // each selected element // (e.g: jQuery("div")) { var $this = $(this); alert($this); }); }; })(jQuery); // usage $(document).ready(function() { // create a new instance of the plugin $(‘selector’).pluginName(options); });
  • 32.  Allow communication between modules via event publishing managed by pub/sub component;  Each module can publish events, subscribe and unsubscribe to events;
  • 33. app.usermodule = (function () { var me = {}; me.onNewFriendNotificaion = function(notification){ alert(notification.from); }; me.init = function(){ $.subscribe('on-new-friend- notificaion', me.onNewFriendNotificaion); }; me.destroy = function(){ $.unsubscribe('on-new- friend-notificaion', me.onNewFriendNotificaion); }; return me; }()); app.streammodule = (function () { var me = {}; me.post = function(){ // do some client logic and notify the other modules $.publish('on-new-friend- notificaion', { from:'user' }); }; return me; }());
  • 34.  String localization;  Dates, times, numbers, and currencies;  Use jQuery Globalize plugin for Dates, times, numbers, and currencies;
  • 35.  Store string resources in JSON format so they would be native to client;  Server string resources per culture;  Build language manager for the string resources;  Load the JSON resources into the language manager;  User the language manager to translate plugins, DOM elements and strings;
  • 36.  Useful for tracking modules state, variables and processes while in development;  Natively supported in all of the new modern browsers;  Use an existing logging framework or wrap your logger around the existing browsers logger;
  • 37. var logger = function(){ var logger = {}; window.onerror = function(message, file, line) { logError(file + ':' + line + 'nn' + message); }; logger.log = function(message){ logError(message); }; function logError(message){ if(console && console.log){ console.log(message); } }; return logger; }();
  • 38.  Add style sheets in the HEAD  Add scripts at the bottom of the <BODY>  Add favicon  Create CSS sprites  Enable GZIP and static resource Caching  Minimize CSS and JavaScript files  Set cookie less domain for static resources
  • 39.  routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
  • 40.  Put all of your icons and assets that you are using for your design into one file. Create CSS file to access the resources. You will minimize n*request per resource time that the browser would call for the separate assets.  Check out Sprite cow – http://www.spritecow.com
  • 41. <system.webServer> <staticContent> <remove fileExtension=".js" /> <remove fileExtension=".css" /> <mimeMap fileExtension=".js" mimeType="text/javascript" /> <mimeMap fileExtension=".css" mimeType="text/css" /> <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="500.00:00:00" /> </staticContent> <urlCompression doStaticCompression="true" doDynamicCompression="true" /> </system.webServer>
  • 43.  Go to your domain hosting account and set a subdomain that point to your web application  Set your static resources to point to the subdomain to avoid cookie data transfer