本文源于公司內部技術交流,如有不當之處,還請指正。
?
Content:
1. What is Data-driven design?
2. WPF revolution.
3. More about ObservableCollection.
4. Question.
1.?What is Data-driven design?
Data-driven design: is a design of using entity or module to control the software how to display and design. Now in Wikipedia, the article had been redirected to Responsibility-driven design which is inspired by the Client/Service Mode. The Client/Service model they refer to assumes that a software client and a software server exchange information based on a contract that both parties commit to adhere to. The client may only make the requests specified, the server must answer them.
簡而言之,廣義上來說數據驅動設計是以數據為中心展開的設計方式,與以往的由界面至數據結構的方式相反,首先要從數據結構/數據模型下手,完善數據控制層/業務邏輯層,最后在到界面的設計。

Summary:?
1 It’s just a different way that how to design software. It’s a design method not writing code directly. 只是一種不同的設計軟件的思想,方式。
2 As usual, we design software from interface to data source, firstly drag user control to panel and secondly write control event. It’s also called up to down design. 通常,我們是從上之下的設計方式,先界面,后模型。
3 On the opposite side, we use down to up design. From data module to user interface, we design around data module that compared with usual design, it’s called Inversion Of Control. 相反,我們是從數據入手展開軟件設計,一切以數據為中心;底層數據驅動開發,界面依賴于數據,也叫做控制反轉。
Application:
1 WCF
First,we make a data module. Like this:

Second, we make a WCF service in order to provider functions around data module.

Learn more: ?http://www.codeproject.com/Articles/91528/How-to-Call-WCF-Services-Synchronously-and-Asynchr
2 WPF Revolution.
Winform?DataBinding:
http://files.cnblogs.com/cuiyansong/WinformDataBindingDemo.7z?
如果在Winform下開發,實現數據的雙向綁定,當然是依靠委托的方式實現的。底層數據模型提供一個廣播委托Speaker,當數據發生改變時,觸發委托通知。一般來講我們需要構建一個通道用于共享并集中管理通道消息Channel,通道將收集上來的消息發送給監聽者Listener。
? WPF DataBinding:
http://files.cnblogs.com/cuiyansong/DatabindingDemo.7z
http://files.cnblogs.com/cuiyansong/Demo_ObservalCollection.7z
WPF 提供了ObservableCollection 實現數據集合的雙向綁定,INotifyCollection是對Module層的數據更新通知,底層實現的代碼與上面的實現方式幾乎相同,而ObservableCollection則是對List進行了二次封裝,提供List.Add,List.Remove級別上的綁定,就是說如果數據集合發生變化,也將會通知相關Listener。
本質上來說,WPF 的ObservableCollection 和 INotifyCollection并未提供什么新鮮的東西,只是一次便捷的封裝。當然這里也要公平的說一下,這2個類只是WPF DataBinding思想的一部分而已,另外還包括界面的動態綁定,屬性的雙向綁定等等,都是一次思想上的革新!

Summary
–1. DataBinding’s essence is a method of using delegate which need both listener and speaker.
–2. WPF build-in support XAML Binding grammar.
–3. DataBinding is not just used for implement INotifyCollectionChanged interface, also you can only use the class Binding for yourself binding application.
–4. If you need a list of data support two-way binding, you should use ObservableCollection instead of Ilist.
–5. Data-Binding is just a method of software design not just only in WPF.