http://www.opitz-consulting.com/go/3-4-11
JavaScript applications have yet become increasingly powerful but likewise increasingly complex. How can such an application remain maintainable and testable in spite of its growth? Design pattern like data binding, dependency injection and modular design.
OPITZ CONSULTING Senior Solution Architect Stefan Scheidt at JavaScript Conference, Düsseldorf, Germany, 27/02/2012.
43. jQuery Mobile & AngularJS
The problem:
DOM transformations
done by jQuery Mobile and AngularJS
need to be coordinated!
44. jQuery Mobile & AngularJS
Our Solution:
jQuery Mobile Angular Adapter
45. jQuery Mobile Angular Adapter
Integration of jQuery Mobile & AngularJS
Extentions for mobile web development
Open source on GitHub
https://github.com/tigbro/jquery-mobile-angular-adapter
47. Dependency Injection is a design pattern
whose purpose is to reduce the dependencies
between components.
It delegates the responsibility for creation and
wiring of objects to an externaly configurable
framework.
http://de.wikipedia.org/wiki/Dependency_Injection
48. Dependency Injection is a design pattern
whose purpose is to reduce the dependencies
between components.
It delegates the responsibility for creation and
wiring of objects to an externaly configurable
framework.
http://de.wikipedia.org/wiki/Dependency_Injection
49. Sample: Calling the backend
var readUrl = 'https://secure.openkeyval.org/';
TodoController.prototype.refreshTodos() {
var self = this;
read(readUrl, function(response) {
self.todos = response;
});
}
50. Sample: Calling the backend
var readUrl = 'https://secure.openkeyval.org/';
TodoController.prototype.refreshTodos() {
var self = this;
read(readUrl, function(response) {
self.todos = response;
});
}
51. Sample: Calling the backend
var readUrl = 'https://secure.openkeyval.org/';
function read(key, success) {
var url = readUrl + key;
waitdialog.show();
jsonp(url, function(data) {
success(data);
waitdialog.hide();
});
}
52. Sample: Calling the backend
var readUrl = 'https://secure.openkeyval.org/';
function read(key, success) {
var url = readUrl + key;
waitdialog.show();
jsonp(url, function(data) {
success(data);
waitdialog.hide();
});
}
53. Sample: Calling the backend
var readUrl = 'https://secure.openkeyval.org/';
function read(key, success) {
var url = readUrl + key;
waitdialog.show();
jsonp(url, function(data) {
success(data);
waitdialog.hide();
});
}
54. Sample: Calling the backend
waitDialog
todoController todoStore key value
key value key value ... ...
refreshToDos ... read ...
todoStore waitDialog
jsonp jsonp
key value
... ...
created created by
with "new" Factories
55. Sample: Calling the backend
waitDialog
todoController todoStore key value
key value key value ... ...
refreshToDos ... read ...
todoStore waitDialog
jsonp jsonp
key value
... ...
created by
Dependency Injection
56. Angular: DI for Services
angular.service('jsonp', jsonpFactory);
angular.service('waitdialog', waitdialogFactory);
57. Angular: DI for Services
angular.service('jsonp', jsonpFactory);
angular.service('waitdialog', waitdialogFactory);
function todoStoreFactory() {
function read(key, success) { ... }
// ...
return {
read: read
// ...
}
}
58. Angular: DI for Services
angular.service('jsonp', jsonpFactory);
angular.service('waitdialog', waitdialogFactory);
function todoStoreFactory(jsonp, waitdialog) {
function read(key, success) { ... }
// ...
return {
read: read,
// ...
}
}
todoStoreFactory.$inject = ['jsonp', 'waitdialog'];
59. Angular: DI for Services
angular.service('jsonp', jsonpFactory);
angular.service('waitdialog', waitdialogFactory);
function todoStoreFactory(jsonp, waitdialog) {
function read(key, success) { ... }
// ...
return {
read: read
// ...
}
}
todoStoreFactory.$inject = ['jsonp', 'waitdialog'];
angular.service('todoStore', todoStoreFactory);
60. Angular: DI for Controller
// ...
angular.service('todoStore', ...);
61. Angular: DI for Controller
// ...
angular.service('todoStore', ...);
function TodoController(todoStore) {
// do something with todoStore ...
}
TodoController.$inject = ['todoStore'];
62. Summary
There are quite a lot of useful design patterns
for the development of JavaScript Web Apps!
Use them!
63. Summary
Libraries and Frameworks
can help you to get your stuff done!
64. In the hive 11: nectar and pollen
by Max xx, http://www.flickr.com/photos/max_westby/4567762490
Books
By Rodrigo Galindez, http://www.flickr.com/photos/rodrigogalindez/4637637337/
IMG_1300-Edit
by Susan E Adams, http://www.flickr.com/photos/susanad813/3912914836/
Doble Via
by amslerPIX, http://www.flickr.com/photos/amslerpix/6242266697/
MacBook Pro Keyboard
by superstrikertwo, http://www.flickr.com/photos/superstrikertwo/4989727256/
Stubborn Last Drop
by RogueSun Media, http://www.flickr.com/photos/shuttercat7/627798443/