SlideShare a Scribd company logo
開發複雜網頁應用的黃金法則
The Method to Build Complex Web App
Destructure Piconion
https://piconion.com/
Piconion 影像處理軟體的開發、經營
Vision
願景
Development
開發
User Feedback
使用者回饋
Monetization
盈利
本次以開發經驗分享為主題,其他為輔
Build Complex Web App
建構複雜的網頁應用程式
The Key
事情很簡單
Modularize
模組化
Keep Modularizing
更多的模組化
Hierarchical Structure
一層不夠,不會兩層嗎?
Lovely, Totally Clean Code
用心寫出可愛、完美、乾淨的程式碼
Holy Bullshit
The Truth
真相
Dirty Code Always Exists
噁爛的、難以被有效模組化的程式碼
會永遠存在、且越來越失控
The Key is ...
真正的關鍵是 ...
Accept it
打不贏,就接受它
Name it
然後給它取個名字
Glue Code
General Code Responsibility
Application State
User Interface Data Management
Glue Code
Details
來一點細節吧
File System in Piconion
var FileState=function(){
this.id; this.name;
this.current; this.modified;
this.set=function(){};
this.get=function(){};
};
var FileUI=function(){
this.elem;
this.create=function(){}
this.modify=function(){}
this.remove=function(){}
};
var FileData=function(){
this.img;
this.load=function(){}
this.modify=function(){}
this.dispose=function(){}
}
Glue Code
Modules in File System
FileState
FileUI FileData
Blue rects are modules, should meet requirements listed below:
● Clear purpose: 清楚的權責。
● Independant: 獨立運作,彼此不互相影響。
● Reusable: 可重複利用。
● Unit Testable: 可做單元測試。
Glue Code in File System
Glue
Green triangle is glue code, do any other dirty works:
● Set up & Initialize. 完成初期設定。
● Control application flow. 控制應用流程。
● Pass data between modules. 傳遞模組間的資料。
● Do unit test. 加入單元測試程式。
More Details
更多的細節
Another Key is ...
還有另外一個關鍵是 ...
Pure Function
Pure Function
INPUT OUTPUT
NO SIDE EFFECTS
沒有副作用
在同樣的輸入下,永遠會得到一樣的輸出
Why Pure Function?
● Easy to do unit test. 容易做單元測試
● Flexible and Reusable. 彈性且可重複使用
● Simple. 減少影響整體系統的函式,能有效降低系統複雜度
● Should be the interface of modules.
是建立模組介面的優良選擇。
Where Pure Functions Work Best?
var FileState=function(){
this.current;
this.modified;
this.set=function(){};
this.get=function(){};
};
var FileUI=function(){
this.elem;
this.create=function(){};
this.modify=function(){};
this.remove=function(){};
};
var FileData=function(){
this.id; this.name; this.img;
this.load=function(){};
this.modify=function(){};
this.dispose=function(){};
}
Glue Code
(File Object)
File Object
(Glue Code)
var File=function(){
// Ignore FileState, FileData, and FileUI Details
var fileState=new FileState();
var fileData=new FileData();
var fileUI=new FileUI();
this.init=function(){
fileData.load(function(){
fileState.set("current", true);
fileUI.create({
"current":fileState.get("current"),
"name":fileState.get("name"),
"img":fileState.get("img")
});
});
};
};
(new File()).init();
What we write
var FileUI=function(){
this.elem;
this.create=function(inputs){
this.elem=document.createElement("div");
this.elem.className=
inputs.current?"current-file":"file";
this.elem.title=inputs.name;
};
this.modify=function(){};
this.remove=function(){};
};
What we DON’T write
var FileUI=function(){
this.elem;
this.create=function(){
this.elem=document.createElement("div");
this.elem.className=
fileState.current?"current-file":"file";
this.elem.title=fileData.name;
};
this.modify=function(){};
this.remove=function(){};
};
Hierarchical Structure
一層不夠,不會兩層嗎?
File Management System in Piconion
Current File
(State)
File Bar
(UI)
Array of File Object
(Data)
File
Manager
File Management System in Piconion
var FileManager=function(){
var files=[]; // Array of File Object / Data
var fileCurrent=null; // State
var fileBar=new FileBar(); // UI
this.loadFile=function(){};
this.changeCurrentFile=function(){};
this.disposeFile=function(){};
};
FileState
FileUI FileData
Encapsulated
File Structure
Done
Piconion Overview
FileManager
TransformManagerSelectionManager
PathManagerLayerManager
HistoryManager
Basic HTML/CSS EventDispatcher
Custom UI
Component
App State App Constant Language Pack
UI
State
Data
What’s New
支援 Google Drive、觸控介面、觸控筆
多檔案編輯、路徑圖層等等
FAQ
問答時間
其實還有 XD
已知 未知
已知 邊逛 PTT 邊達成目標。
仔細規劃、評估風險後達
成目標。
未知
程式寫到一半,哀號一聲
,這麼簡單的議題居然沒
注意到 => 時間x2
程式寫到一半,因為神祕
的原因卡住,要先找出問
題根源,再進一步設法解
決 => 時間 ∞
市場、資金
環境巨變
時間壓力
成本壓力
Piconion 影像處理軟體的開發、經營
Vision
願景
Development
開發
User Feedback
使用者回饋
Monetization
盈利
用一張投影片聊聊其他主題吧
TRUE END
謝謝大家
彭彭的線上課程教學
在台大擔任前端工程講師超過八年
https://training.pada-x.com/

More Related Content

Similar to 開發複雜網頁應用的黃金法則

Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天Gelis Wu
 
Web App or Native App
Web App or Native AppWeb App or Native App
Web App or Native AppYu Wei Shang
 
【项目分享】赶集移动Web App开发总结
【项目分享】赶集移动Web App开发总结 【项目分享】赶集移动Web App开发总结
【项目分享】赶集移动Web App开发总结 yangdj
 
開源 x 節流:企業導入經驗分享 (一)+(二) [2016/07/21] A+A Space 開源講座
開源 x 節流:企業導入經驗分享 (一)+(二)  [2016/07/21] A+A Space 開源講座開源 x 節流:企業導入經驗分享 (一)+(二)  [2016/07/21] A+A Space 開源講座
開源 x 節流:企業導入經驗分享 (一)+(二) [2016/07/21] A+A Space 開源講座
Jason Cheng
 
悠播Hd
悠播Hd悠播Hd
悠播Hd
benimaru0407
 
#3月瘋行動 打造行動網站,掌上流量一網打盡
#3月瘋行動 打造行動網站,掌上流量一網打盡#3月瘋行動 打造行動網站,掌上流量一網打盡
#3月瘋行動 打造行動網站,掌上流量一網打盡
AdWordsGreaterChina
 
Mugeda 36kr
Mugeda 36krMugeda 36kr
Mugeda 36kr36Kr.com
 
MobileWebAppFramework_V5_design
MobileWebAppFramework_V5_designMobileWebAppFramework_V5_design
MobileWebAppFramework_V5_design
Jackson Tian
 
測試網在開發 因太區塊鏈 dApp 中的重要性.pdf
測試網在開發 因太區塊鏈 dApp 中的重要性.pdf測試網在開發 因太區塊鏈 dApp 中的重要性.pdf
測試網在開發 因太區塊鏈 dApp 中的重要性.pdf
因太區塊鏈
 
36氪月报201202期
36氪月报201202期36氪月报201202期
36氪月报201202期Chada Chiu
 
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
August Lin
 
移动互联网的机遇与挑战
移动互联网的机遇与挑战移动互联网的机遇与挑战
移动互联网的机遇与挑战
Courtney Chow
 
Android studio 之 i beacon 藍芽應用開發學習
Android studio 之 i beacon 藍芽應用開發學習Android studio 之 i beacon 藍芽應用開發學習
Android studio 之 i beacon 藍芽應用開發學習
政斌 楊
 
Inspire dgt 網路技術分享_手機版網頁製作簡介_20111221
Inspire dgt 網路技術分享_手機版網頁製作簡介_20111221Inspire dgt 網路技術分享_手機版網頁製作簡介_20111221
Inspire dgt 網路技術分享_手機版網頁製作簡介_20111221inspire digital
 
20120912 windows 8 開發概論
20120912 windows 8 開發概論20120912 windows 8 開發概論
20120912 windows 8 開發概論
Meng-Ru (Raymond) Tsai
 
MVC MVVM MVVMC
MVC MVVM MVVMCMVC MVVM MVVMC
MVC MVVM MVVMC
Ng Hui Qin
 
面對移動化App挑戰的架構設計
面對移動化App挑戰的架構設計面對移動化App挑戰的架構設計
面對移動化App挑戰的架構設計
Clark
 
李昶翰(Reborn):工作流程自動化 Microsoft Power Platform – 運用 Power BI + Power Automate ...
李昶翰(Reborn):工作流程自動化 Microsoft Power Platform –  運用 Power BI + Power Automate ...李昶翰(Reborn):工作流程自動化 Microsoft Power Platform –  運用 Power BI + Power Automate ...
李昶翰(Reborn):工作流程自動化 Microsoft Power Platform – 運用 Power BI + Power Automate ...
開拓文教基金會
 
那些設計時容易忽略的事情 @Front-End Developers Taiwan Party 2
那些設計時容易忽略的事情 @Front-End Developers Taiwan Party 2那些設計時容易忽略的事情 @Front-End Developers Taiwan Party 2
那些設計時容易忽略的事情 @Front-End Developers Taiwan Party 2
WeiHan Hung
 
淘宝网前端应用与发展
淘宝网前端应用与发展淘宝网前端应用与发展
淘宝网前端应用与发展
taobao.com
 

Similar to 開發複雜網頁應用的黃金法則 (20)

Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
Visual studio 2012 與 asp.net 4.5 (新功能與開發介紹) 第一天
 
Web App or Native App
Web App or Native AppWeb App or Native App
Web App or Native App
 
【项目分享】赶集移动Web App开发总结
【项目分享】赶集移动Web App开发总结 【项目分享】赶集移动Web App开发总结
【项目分享】赶集移动Web App开发总结
 
開源 x 節流:企業導入經驗分享 (一)+(二) [2016/07/21] A+A Space 開源講座
開源 x 節流:企業導入經驗分享 (一)+(二)  [2016/07/21] A+A Space 開源講座開源 x 節流:企業導入經驗分享 (一)+(二)  [2016/07/21] A+A Space 開源講座
開源 x 節流:企業導入經驗分享 (一)+(二) [2016/07/21] A+A Space 開源講座
 
悠播Hd
悠播Hd悠播Hd
悠播Hd
 
#3月瘋行動 打造行動網站,掌上流量一網打盡
#3月瘋行動 打造行動網站,掌上流量一網打盡#3月瘋行動 打造行動網站,掌上流量一網打盡
#3月瘋行動 打造行動網站,掌上流量一網打盡
 
Mugeda 36kr
Mugeda 36krMugeda 36kr
Mugeda 36kr
 
MobileWebAppFramework_V5_design
MobileWebAppFramework_V5_designMobileWebAppFramework_V5_design
MobileWebAppFramework_V5_design
 
測試網在開發 因太區塊鏈 dApp 中的重要性.pdf
測試網在開發 因太區塊鏈 dApp 中的重要性.pdf測試網在開發 因太區塊鏈 dApp 中的重要性.pdf
測試網在開發 因太區塊鏈 dApp 中的重要性.pdf
 
36氪月报201202期
36氪月报201202期36氪月报201202期
36氪月报201202期
 
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
IoT Cloud Platforms- Players, Vendors and Vertical Segments -20160519
 
移动互联网的机遇与挑战
移动互联网的机遇与挑战移动互联网的机遇与挑战
移动互联网的机遇与挑战
 
Android studio 之 i beacon 藍芽應用開發學習
Android studio 之 i beacon 藍芽應用開發學習Android studio 之 i beacon 藍芽應用開發學習
Android studio 之 i beacon 藍芽應用開發學習
 
Inspire dgt 網路技術分享_手機版網頁製作簡介_20111221
Inspire dgt 網路技術分享_手機版網頁製作簡介_20111221Inspire dgt 網路技術分享_手機版網頁製作簡介_20111221
Inspire dgt 網路技術分享_手機版網頁製作簡介_20111221
 
20120912 windows 8 開發概論
20120912 windows 8 開發概論20120912 windows 8 開發概論
20120912 windows 8 開發概論
 
MVC MVVM MVVMC
MVC MVVM MVVMCMVC MVVM MVVMC
MVC MVVM MVVMC
 
面對移動化App挑戰的架構設計
面對移動化App挑戰的架構設計面對移動化App挑戰的架構設計
面對移動化App挑戰的架構設計
 
李昶翰(Reborn):工作流程自動化 Microsoft Power Platform – 運用 Power BI + Power Automate ...
李昶翰(Reborn):工作流程自動化 Microsoft Power Platform –  運用 Power BI + Power Automate ...李昶翰(Reborn):工作流程自動化 Microsoft Power Platform –  運用 Power BI + Power Automate ...
李昶翰(Reborn):工作流程自動化 Microsoft Power Platform – 運用 Power BI + Power Automate ...
 
那些設計時容易忽略的事情 @Front-End Developers Taiwan Party 2
那些設計時容易忽略的事情 @Front-End Developers Taiwan Party 2那些設計時容易忽略的事情 @Front-End Developers Taiwan Party 2
那些設計時容易忽略的事情 @Front-End Developers Taiwan Party 2
 
淘宝网前端应用与发展
淘宝网前端应用与发展淘宝网前端应用与发展
淘宝网前端应用与发展
 

開發複雜網頁應用的黃金法則