The document discusses a template-based modular architecture for advanced JavaScript applications. It covers key concepts like modular design, modules, templates, and a dispatcher. For modules, it describes elements, encapsulation, and advantages like independence and decomposability. It then covers templates for importing styles, scripts, and HTML. The dispatcher section explains principles like Uniform Module Identifiers and strategies for dispatching and routing. A case study demonstrates system decomposition into modules and their development. The document concludes with discussions around module deployment and performance improvements.
4. Modular
• Advantages
– Several programmers can work on individual
programs at the same time, thus, making
development of program faster
– Concerns are separated such that modules
perform logically discrete functions
– The code base is easier to debug, update and
modify
11. Template
• Import Script
<script>
var a = 'aaaaa';
var b = 'bbbbb';
</script>
<script src="http://b.126.net/r/c.js"></script>
<textarea name="js">
var a = 'aaaaa';
var b = 'bbbbb';
</textarea>
<textarea name="js"
data-src="http://b.126.net/r/c.js">
</textarea>
<textarea name="js"
data-src="http://b.126.net/r/c.js">
var a = 'aaaaa';
var b = 'bbbbb';
</textarea>
17. Dispatcher
• UMI
– Uniform Module Identifier
– Format
• Path of URI,e.g. /m/m0/
• Begin with “/”
• Begin with“/?”if private module
– Dependency
• e.g. parent of “/m/m0/”and “/m/m1/”is “/m”
18. m
blog
list tag/
setting
/ account permission
/ edu
/
/
/
/ /
• UMI
– Split Dependency by UMI
Blog
BlogList BlogTags
Setting
Account
Profile EduExp
Permission
System
Dispatcher
19. Dispatcher
• UMI
– Mapping UMI to Module
m
blog
list tag/
setting
/ account permission
/ edu
/
/
/
/ /
System
Blog Setting
BlogList BlogTags
Account
PermissionProfile
EduExp
BlogList
/m/blog/list/
20. Dispatcher
• UMI
– Mapping UMI to html
BlogList
<style> …
<html> …
<script> …
module.html
BlogList
/m/blog/list/
21. Dispatcher
• UMI
– Mapping UMI to html
m
blog
list tag/
setting
/ account permission
/ edu
/
/
/
/ /
module/frame.html
module/blog/frame.html module/setting/frame.html
module/blog/list.html
module/setting/account/frame.html
module/setting/account/edu.html
22. Dispatcher
• Strategy
– dispatch to /m/blog/list/
• Check action
• Load or Dispatch
• Waiting Loaded Callback
m
blog
list tag/
setting
/ account permission
/ edu
/
/
/
/ /
23. Dispatcher
• Strategy
– dispatch to /m/setting/account/
• Find common root
• Hide : source -> common
• Refresh : root -> common
• Show : common -> target
m
blog
list tag/
setting
/ account permission
/ edu
/
/
/
/ /
30. Case Study
• System Decomposition
Blog
BlogList BlogTags
Setting
Account
Profile EduExp
Permission
System
m
blog
list tag/
setting
/ account permission
/ edu
/
/
/
/ // / /
/
/
m
blog setting
account
31. Case Study
• System Decomposition
收件箱切换
类别列表
标签列表日志列表
?
blog
tag listbox
/
/ /
class
/ //?/blog/box//?/blog/tag//?/blog/list//?/blog/class/