<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>I&#039;m CaLendarW Blog &#187; SoC</title>
	<atom:link href="http://wongkalun.idv.hk/tag/soc/feed/" rel="self" type="application/rss+xml" />
	<link>http://wongkalun.idv.hk</link>
	<description>任何時間，都要用內心既一點光，照亮世界</description>
	<lastBuildDate>Tue, 17 Aug 2010 15:00:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Separation Of Concerns</title>
		<link>http://wongkalun.idv.hk/2009/04/26/separation-of-concerns/</link>
		<comments>http://wongkalun.idv.hk/2009/04/26/separation-of-concerns/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 08:20:24 +0000</pubDate>
		<dc:creator>calendarw</dc:creator>
				<category><![CDATA[architecture]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[SoC]]></category>
		<category><![CDATA[精華]]></category>

		<guid isPermaLink="false">http://wongkalun.idv.hk/?p=477</guid>
		<description><![CDATA[係軟件設計方面, 其實主要都想將唔同既 Concern 分開, 以我做開主要有以下幾個: Flow / Business Logic Input (Import Data, Interface for 3rd Party) Output (User Interface, Report) Database Logging Permission 在以上幾個 Concern 上, 而 Logging 同 Permission 呢兩樣野其實應該可以重用, 而且應該可以視為另一個軟件 / Domain Area. Database 使用方面, 因為市面有不同種類既選擇, 而為左可以應用係唔同 Database 上, 好多人都會加上一個 Data Access Layer, 正常既 implement 手法都係 Object Relational Mapping, 在 .net 主要有 LGPL [...]]]></description>
			<content:encoded><![CDATA[<p>係軟件設計方面, 其實主要都想將唔同既 Concern 分開, 以我做開主要有以下幾個:</p>
<ul>
<li>Flow / Business Logic</li>
<li>Input (Import Data, Interface for 3rd Party)</li>
<li>Output (User Interface, Report)</li>
<li>Database</li>
<li>Logging</li>
<li>Permission</li>
</ul>
<p>在以上幾個 Concern 上, 而 Logging 同 Permission 呢兩樣野其實應該可以重用, 而且應該可以視為另一個軟件 / Domain Area.</p>
<p>Database 使用方面, 因為市面有不同種類既選擇, 而為左可以應用係唔同 Database 上, 好多人都會加上一個 <a href="http://en.wikipedia.org/wiki/Data_Access_Object">Data Access Layer</a>, 正常既 implement 手法都係 <a href="http://en.wikipedia.org/wiki/Object-relational_mapping">Object Relational Mapping</a>, 在 .net 主要有 <a href="http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License">LGPL License</a> 既 <a href="http://nhforge.org/">NHibernate</a>,  Castle Project 既<a href="http://www.castleproject.org/activerecord/index.html ">Active Record</a>, 又或者係 .net 3.5 既 <a href="http://msdn.microsoft.com/en-us/library/bb386976.aspx">Linq To SQL</a> 及 <a href="http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx">Entity Framework</a>, 這些 Module 已經被外國引用成為主流, 因為使用者不用因應不同既 Database 而寫大同小異既 SQL, 避免了因小異而不段尋找問題, 只要學習一套, 其他由 OR Mapper 做便好了.</p>
<p>Logging 方面, Debug Log 其實可以用 <a href="http://en.wikipedia.org/wiki/Apache_License">Apache License</a> 既 <a href="http://logging.apache.org/log4net/index.html">log4net</a>, 而 Audit Log 我覺得應該可以視為另一個軟件而寫到一個 Lib 黎比全公司用, 以統一全公司軟件開發基礎.</p>
<p>Permission 方面主要有 <a href="http://en.wikipedia.org/wiki/Authentication">Authentication</a> 同 <a href="http://en.wikipedia.org/wiki/Authorization">Authorization</a> 兩個部份, 我覺得可以寫得開一個 Lib, 因應唔同需要 (e.g. 用 AD or 自己既 Login Table) 而各自使用同一個 Interface 既唔同 Implementation, 總好過不同 Project 都用緊不同既處理手法.</p>
<p>Input 同 Output 方面其實都幾難重用, 不過都應該可以寫到一 d 相對應既 Lib (e.g. Import/Export Excel, Customize User Control 或者既定的 3rd Party Solution).</p>
<p>Flow 其實係最難重用既部份, 因為應該唔同 Project 都有唔同既 Flow / Business Logic, 而常見既處理手法都會使用 <a href="http://en.wikipedia.org/wiki/Object-oriented_design">Object Oriented Design</a>, 而為了保證質素, 外國 (包括 Microsoft) 寫左套測試系統黎令做 Automate Testing, 有早期自己用開既 <a href="http://www.nunit.org/index.php">NUnit</a>, 或者 Visual Studio 2005 打後既 <a href="http://msdn.microsoft.com/en-us/library/ms243147(VS.80).aspx">Unit Testing Framework</a>, 當然仲有好多其他既 Implementation, 只不過自己用開 NUnit 而無再留意.</p>
<p>綜合以上不同既 Concern, 其實除左 Flow/Business Logic, Input 同 Output 之外, 其他部份應該都可以重用, 如果每個 Project 都可以重用這些 Module, 寫軟件既時間應該可以集中一點在不能重用既部份而提高用家對軟件質素既評價, 亦可以有時間做 Performance Turning 及 Unit Testing, 使軟件能夠提升質量, 有關點解要 Testing 既資料可以參考舊 <a href="http://wongkalun.idv.hk/2009/04/15/why-automate-test/">Post</a>, 而 Performance Testing 其實亦可以靠 Unit Test 黎做監察 (詳見 <a href="http://www.amazon.com/Pragmatic-Unit-Testing-NUnit-2nd/dp/0977616673/">Pragmatic Unit Testing in C# with NUnit</a> 內有關 Performance Testing 一節)</p>
<p>重用既除左可以減少需要 Implement 既時間外, 對新人黎講都會容易跟, 因為套套系統都用緊同一樣野可以減省 Pickup 現有系統既時間.  不過對於重用方面, 公司既軟件管理政策亦同樣重要, 如果個個 Project 都係 Copy 一套出黎用, 那麼發現一個 Bug 就要搵晒全公司既所有 Project 一個個改, 這些處理手法在 <a href="http://www.amazon.com/AntiPatterns-Refactoring-Software-Architectures-Projects/dp/0471197130/">AntiPattern</a> 內亦有提及, 往往做成不良後果.</p>
<p>不過以上既推論都有重要既假設: 一個好既 OO Design 同 Design for Reuse.  如果設計得唔好, 就沒有人會用, 如果不是為重用而設計, 就不能重用.</p>
<p>對我在舊公司管理及維持左 Reusable Lib of Web Module, Data Module 同 Common Module 及不同 Internal Project 年幾時間既我, 加上接近七年前大專開始既軟件開發生涯, 在 OO Design 同 Design for Reuse 都自覺有相當既經驗, 雖然亦有好多不足既地方, 但亦希望跟住呢條路行.  而因未發新公司有現醒啱用既 Lib , 所以自己寫左一些重用到既 Lib, 加上 Project 開始繁忙而盡量希望在 Project 內實行軟件架構, 短期內應該有好多機會提升自己在設計及實行方面既經驗, 希望現實真係可以咁 Ideal 啦.</p>



		<!-- Added by WP-DragToShare-eXtended Plugin -->
		<script type="text/javascript">
			dtsv.dtse_post_477_permalink = 'http://wongkalun.idv.hk/2009/04/26/separation-of-concerns/';
			dtsv.dtse_post_477_title = 'Separation Of Concerns';
		</script>
		<!-- End of WP-DragToShare-eXtended Plugin -->]]></content:encoded>
			<wfw:commentRss>http://wongkalun.idv.hk/2009/04/26/separation-of-concerns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
