<?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>軟體開發隨筆 &#8211; Larry的午茶時光</title>
	<atom:link href="https://blog.yuyansoftware.com.tw/category/software-development-notes/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.yuyansoftware.com.tw</link>
	<description></description>
	<lastBuildDate>Wed, 26 Nov 2025 03:17:48 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.yuyansoftware.com.tw/wp-content/uploads/2022/10/favicon-45x45.png</url>
	<title>軟體開發隨筆 &#8211; Larry的午茶時光</title>
	<link>https://blog.yuyansoftware.com.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>MySQL Key 與 Index 的差異？Primary 與 Unique key 的差異？Unique key 能否為 null？</title>
		<link>https://blog.yuyansoftware.com.tw/2018/10/mysql-key-index/</link>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Mon, 15 Oct 2018 03:44:00 +0000</pubDate>
				<category><![CDATA[好文記錄與分享]]></category>
		<category><![CDATA[軟體開發隨筆]]></category>
		<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[Key 與 index 的差異？Key 包含了兩個功能 1. 約束 (constraint) 2. 索引 (index), 也就是 key 功能上包含了 index. 以 Primary key 來說，他的特性是 1. Unique constraint. 2. Each table can only have one Primary key. 3. Cannot be null.]]></description>
										<content:encoded><![CDATA[
<p>圖片來源 <a href="https://zh.wikipedia.org/wiki/MySQL" target="_blank" rel="noreferrer noopener nofollow">https://zh.wikipedia.org/wiki/MySQL</a></p>



<p>之前看到一篇關於 MySQL index / key 的文章，以中文 MySQL 文章來說，larry 覺得寫得滿好的，分享給大家<br><a href="https://blog.csdn.net/nanaMasuda/article/details/52543177" target="_blank" rel="noreferrer noopener nofollow">https://blog.csdn.net/nanaMasuda/article/details/52543177</a><br>(文章內的「索引」就是 index)</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>&#8220;索引被用來快速找出在一個列上用一特定值的行。沒有索引，MySQL不得不首先以第一條記錄開始並然後讀完整個表直到它找出相關的行。&#8221;</p>
</blockquote>



<p>文章第一句就點出 index 的主要功能：快速檢索。為啥可以快速檢索？因為 MySQL index 會建一物理結構 BTree 加快檢索，也可以想成是用空間換取速度。</p>



<h2 class="wp-block-heading">Key 與 Index 的差異？</h2>



<h3 class="wp-block-heading">Key 包含了兩個功能</h3>



<ol class="wp-block-list">
<li>約束 (constraint)，包含本文下方提到的 Unique constraint.</li>



<li>索引 (index)，也就是 key 功能上包含了 index.</li>
</ol>



<h2 class="wp-block-heading">Primary 與 Unique key 的差異？</h2>



<h3 class="wp-block-heading">Primary key 的特性是</h3>



<ol class="wp-block-list">
<li>Unique constraint.</li>



<li>Each table can only have one Primary key.</li>



<li>Cannot be null. </li>
</ol>



<h3 class="wp-block-heading">Unique key 的特性是</h3>



<ol class="wp-block-list">
<li>Unique constraint.</li>



<li>Each table can have multiple Unique&nbsp;keys.</li>



<li>Can be null. </li>
</ol>



<p>當然，請記得所有的 key 都包含 index 的功能。</p>



<h2 class="wp-block-heading">Unique key 能否為 null？</h2>



<p>larry 有做一些實驗跟查找文章<br><a href="http://www.mysqltutorial.org/mysql-unique/" target="_blank" rel="noreferrer noopener nofollow">http://www.mysqltutorial.org/mysql-unique/</a></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>&#8220;Unlike other database systems, MySQL considers NULL values as distinct values. Therefore, you can have multiple NULL values in the UNIQUE index.<br><br>This is how MySQL was designed. It is not a bug even though it was reported as a bug.&#8221;</p>
</blockquote>



<p>所以以 MySQL 來說，Unique key 是可以為 null 的。</p>



<p>相關文章：<a href="https://blog.yuyansoftware.com.tw/2015/12/mysql-server-mac/">MySQL server 在 Mac 上關不掉的問題</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>MySQL server 在 Mac 上關不掉的問題</title>
		<link>https://blog.yuyansoftware.com.tw/2015/12/mysql-server-mac/</link>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Mon, 21 Dec 2015 06:15:00 +0000</pubDate>
				<category><![CDATA[軟體開發隨筆]]></category>
		<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://test234.yuyansoftware.com.tw/2015/12/21/mysql-server-%e5%9c%a8-mac-%e4%b8%8a%e9%97%9c%e4%b8%8d%e6%8e%89%e7%9a%84%e5%95%8f%e9%a1%8c/</guid>

					<description><![CDATA[MacOS 系統在開機時會 load 上述路徑的 plist files, 然後要特別注意你的 plist file 是否有 KeepAlive, RunAtLoad 兩個 tag, 如果你不希望該 service keep alive 或 run at load 的話，請做適當的設定。]]></description>
										<content:encoded><![CDATA[
<p>圖片來源 <a href="https://zh.wikipedia.org/wiki/MySQL" target="_blank" rel="noreferrer noopener nofollow">https://zh.wikipedia.org/wiki/MySQL</a></p>



<p>這兩天一直在處理一個很詭異的問題，如題：MySQL server 在 Mac 上關不掉。</p>



<p>試了直接砍 process，不行，系統會產生新的 mysql process。搜尋了不少文章後，才發現<a href="https://blog.yorkxin.org/posts/2011/08/04/osx-launch-daemon-agent/" target="_blank" rel="noreferrer noopener nofollow">這篇文章</a></p>



<p>由上面連結得知，Mac 開機/登入時的 services 有分：</p>



<ul class="wp-block-list">
<li>Launch Daemon</li>



<li>Launch Agent</li>
</ul>



<p>Launch Daemon 在開機時動作，Launch Agent 在使用者登入時動作。</p>



<p>到底什麼是 <strong>Launch Daemon</strong> 呢？其實就是以下這些路徑下的 plist (property list) files:<br>/System/Library/LaunchDaemons<br>/Library/LaunchDaemons</p>



<p>系統在開機時會 load 上述路徑的 plist files, 然後要特別注意你的 plist file 是否有 KeepAlive, RunAtLoad 兩個 tag, 如果你不希望該 service keep alive 或 run at load 的話，請做適當的設定。</p>



<p>上面連結也有提到 <strong>Launch Agent</strong> plist file 的路徑：<br>/System/Library/LaunchAgents<br>/Library/LaunchAgents<br>~/Library/LaunchAgents</p>



<p>總之可以看一下上述幾個路徑底下的 plist file 和其中的設定，像是 mysql 的 plist file 就是在 /Library/LaunchDaemons, 如底下連結所敘：<br><a href="https://dev.mysql.com/doc/refman/5.1/en/osx-installation-launchd.html" target="_blank" rel="noreferrer noopener nofollow">https://dev.mysql.com/doc/refman/5.1/en/osx-installation-launchd.html</a></p>



<p>因為 Larry 將 mysql plist file 刪掉後，再重開機，MySQL server 關不掉的問題就不會再犯了，所以就沒有繼續實驗下去。不過照上文推斷，MySQL server 關不掉的問題應該在裝 MySQL 客戶端工具時就一直存在了…</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Swift (3): about Optional</title>
		<link>https://blog.yuyansoftware.com.tw/2015/11/swift-optional/</link>
					<comments>https://blog.yuyansoftware.com.tw/2015/11/swift-optional/#respond</comments>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Sun, 01 Nov 2015 03:26:00 +0000</pubDate>
				<category><![CDATA[好文記錄與分享]]></category>
		<category><![CDATA[軟體開發隨筆]]></category>
		<category><![CDATA[Swift]]></category>
		<guid isPermaLink="false">http://test234.yuyansoftware.com.tw/2015/11/01/swift-3-about-optional/</guid>

					<description><![CDATA[Marin Todorov&#39;s article:&#160;Swift Optionals: When &#8230; ]]></description>
										<content:encoded><![CDATA[<p><span style="font-size: large;">Marin Todorov&#39;s article:&nbsp;Swift Optionals: When to use if let, when ? and !, when as? and as</span><br />
<a href="http://www.touch-code-magazine.com/swift-optionals-use-let/" target="_blank" rel="noopener noreferrer"><span style="font-size: large;">http://www.touch-code-magazine.com/swift-optionals-use-let/</span></a><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;"><b>The &#8220;class?property&#8221; Syntax</b></span></p>
<pre>controller.navigationController?.pushViewController(myViewController, animated: true)<span style="font-size: large;">
</span></pre>
<p><span style="font-size: large;">如果 controller.navigationController 不為 nil, 執行 function. 如果 controller.navigationController 為 nil, 整行程式碼不執行。他可以替換成：</span></p>
<pre>if controller.navigationController != nil {
    controller.navigationController.pushViewController(myViewController, animated: true)
}</pre>
<p><span style="font-size: large;"><br />
</span><span style="font-size: large;"><b>The &#8220;if let&#8221; Syntax  </b></span></p>
<pre>if let nav = controller.navigationController {
    nav.pushViewController(myViewController, animated: true)
} else {
    //show an alert ot something else
}</pre>
<p><span style="font-size: large;">&#8220;if let&#8221; 的語法隱含了 &#8220;and if nav != nil&#8221;. 當你有多行程式碼需要 unwrap, use &#8220;if let&#8221;.</span></p>
<p><span style="font-size: large;"><b>The &#8220;as?&#8221; Syntax </b></span></p>
<pre>let myVC = controller.presentedViewController as? MyViewController
myVC?.lastUpdated = NSDate()<span style="font-size: large;">
</span></pre>
<p><span style="font-size: large;">&#8220;as?&#8221; 有點像 C++ 的 dynamic cast, 以上面例子來說，myVC 有可能是 nil. 正因如此，&#8221;as?&#8221; 底下通常要接 &#8220;class?property&#8221;. 另外如果用 &#8220;as&#8221; 而不是 &#8220;as?&#8221; (沒有問號)，則是 C++ 的 static cast，上面文章連結也有提到你要 101% 確定可以 cast 才用 &#8220;as&#8221; 去 cast. </span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yuyansoftware.com.tw/2015/11/swift-optional/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Swift (2): about the Navigation</title>
		<link>https://blog.yuyansoftware.com.tw/2015/10/swift-navigation/</link>
					<comments>https://blog.yuyansoftware.com.tw/2015/10/swift-navigation/#respond</comments>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Thu, 22 Oct 2015 07:35:00 +0000</pubDate>
				<category><![CDATA[軟體開發隨筆]]></category>
		<category><![CDATA[Swift]]></category>
		<guid isPermaLink="false">http://test234.yuyansoftware.com.tw/2015/10/22/swift-2-about-the-navigation/</guid>

					<description><![CDATA[當你將一個 Navigation Controller 加入到 View (或是 View Controlle &#8230; ]]></description>
										<content:encoded><![CDATA[<p><span style="font-size: large;">當你將一個 Navigation Controller 加入到 View (或是 View Controller, 效果一樣)，storyboard 上會新增一個 Navigation Controller Scene, 該 View 的同一層 (以 Document Outline 的架構來說) 會有一個 Navigation Item (也可以稱之為 navigation bar). 新增的 Navigation Controller 會與 View Controller 以 pic1 連結，官方文件稱之 &#8220;The (table) view controller is the navigation controller&#39;s root view controller.&#8221; </span><br />
<span style="font-size: large;"><br />
</span></p>
<table align="center" cellpadding="0" cellspacing="0" style="margin-left: auto; margin-right: auto; text-align: center;">
<tbody>
<tr>
<td style="text-align: center;"><a href="http://1.bp.blogspot.com/-1EBex0eqnpI/ViXKkY1v4OI/AAAAAAAAAEI/rWPS7rBb2X4/s1600/pic1.png" style="margin-left: auto; margin-right: auto;"><span style="font-size: large;"><img decoding="async" border="0" src="https://1.bp.blogspot.com/-1EBex0eqnpI/ViXKkY1v4OI/AAAAAAAAAEI/rWPS7rBb2X4/s1600/pic1.png"></span></a></td>
</tr>
<tr>
<td style="text-align: center;"><span style="font-size: large;">pic1</span></td>
</tr>
</tbody>
</table>
<p><span style="font-size: large;">拖拉一個 &#8220;Bar Button Item&#8221; 到 navigation bar, 在右邊 attributes inspector 可調整 &#8220;Bar Button Item&#8221; 為 Add, Edit Done, Cancel 等一般我們在 App 上方看到的。Control-drag 剛剛新增的 bar button 到你要到的 view controller, 兩個 view controller 會用 pic2 (或是 pic3) 做連結，切換過去的 view controller 左上角會自然出現 Back.</span><br />
<span style="font-size: large;"><br />
</span></p>
<table align="center" cellpadding="0" cellspacing="0" style="margin-left: auto; margin-right: auto; text-align: center;">
<tbody>
<tr>
<td><a href="http://4.bp.blogspot.com/-XD7TaOctnWQ/ViXKnpqnrBI/AAAAAAAAAEQ/5FTzqDRVqa8/s1600/pic2.png" style="margin-left: auto; margin-right: auto;"><span style="font-size: large;"><img decoding="async" border="0" src="https://4.bp.blogspot.com/-XD7TaOctnWQ/ViXKnpqnrBI/AAAAAAAAAEQ/5FTzqDRVqa8/s1600/pic2.png"></span></a><br />
<span style="font-size: large;">pic2</span></td>
</tr>
<tr>
<td style="text-align: center;"><a href="http://3.bp.blogspot.com/-HmqCtWSr0Q4/ViiOUVzxY-I/AAAAAAAAAEg/WjLnaKveTo0/s1600/pic3.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: large;"><img decoding="async" border="0" src="https://3.bp.blogspot.com/-HmqCtWSr0Q4/ViiOUVzxY-I/AAAAAAAAAEg/WjLnaKveTo0/s1600/pic3.png"></span></a><br />
<span style="font-size: large;">pic3</span></td>
</tr>
</tbody>
</table>
<p><span style="font-size: large;">pic1, 2, 3 在蘋果官方文件稱之為 &#8220;segue&#8221; (發音類似 Segway, 順道一提，Segway 被中國的 Ninebot 買了下來，雷軍是 Ninebot 的股東，所以 10/19 在小米電視3的發佈會上雷軍也發佈了 Ninebot 的產品，這樣應該有助於記憶 segue <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></span><br />
<span style="font-size: large;"></span><br />
<a name="more"></a><span style="font-size: large;">Segue 有幾種類型：push, modal, 等 (Xcode7是叫 show, present modally), 目前的理解是一般在 App 中切換頁面是用 push, modal 比較像之前 Win32 modal dialog 的概念，像是 add new item 就可以用 modal.</span><br />
<span style="font-size: large;">上面提到 push 切換過去的 view controller 左上角自然出現 back, 但是 modal 切換過去的 view controller 是完全空白的 (所以要 dismiss 自己)</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">About the Unwind Segue.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">// In your origin view controller</span><br />
<span style="font-size: large;">override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {</span><br />
<span style="font-size: large;">}&nbsp;</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">// In your destination view controller</span><br />
<span style="font-size: large;">@IBAction func unwindToYourDestinationView(sender: UIStoryboardSegue) {</span><br />
<span style="font-size: large;">}</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">將 storyboard origin view 的 Save button 拉到 origin view 上方的 Exit item, 選擇 unwindToYourDestinationView. 這樣按 Save 時就會觸發上方兩個 function (將 modal view 設定的資料傳回)。</span><span style="font-size: large;">Cancel 的部分簡單藉由 Action handler, 在其中調用 dismissViewControllerAnimated 即可。</span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yuyansoftware.com.tw/2015/10/swift-navigation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Swift (1): Swift 的 data structure</title>
		<link>https://blog.yuyansoftware.com.tw/2015/10/swift-data-structure/</link>
					<comments>https://blog.yuyansoftware.com.tw/2015/10/swift-data-structure/#respond</comments>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Wed, 21 Oct 2015 03:16:00 +0000</pubDate>
				<category><![CDATA[軟體開發隨筆]]></category>
		<category><![CDATA[Swift]]></category>
		<guid isPermaLink="false">http://test234.yuyansoftware.com.tw/2015/10/21/swift-1-swift-%e7%9a%84-data-structure/</guid>

					<description><![CDATA[https://developer.apple.com/library/prerelease/ios/docu &#8230; ]]></description>
										<content:encoded><![CDATA[<p><span style="font-size: large;"><a href="https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/CollectionTypes.html#//apple_ref/doc/uid/TP40014097-CH8-ID105" target="_blank" rel="noopener noreferrer">https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/CollectionTypes.html#//apple_ref/doc/uid/TP40014097-CH8-ID105</a></span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">其實 Swift 與 Python 的 data structures 是類似的，Swift 有: Array, Set, and Dictionary.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">(以下 sample code 都是出自於上方蘋果教程文件)</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;"><b>Array</b></span><br />
<span style="font-size: large;">initializer syntax:</span></p>
<pre>var someInts = [Int]()
var threeDoubles = [Double](count: 3, repeatedValue: 0.0)
</pre>
<p><span style="font-size: large;">array literal (shorthand):</span></p>
<pre>var shoppingList: [String] = ["Eggs", "Milk"]
var shoppingList = ["Eggs", "Milk"]
</pre>
<p><span style="font-size: large;">用 [0], [1], &#8230; subscript syntax (蘋果官方文件取的名詞) 來存取 member.</span><br />
<span style="font-size: large;"></span><br />
<a name="more"></a><span style="font-size: large;"><b>Set</b></span><br />
<span style="font-size: large;">initializer syntax:</span></p>
<pre>var letters = Set&lt;Character&gt;()</pre>
<p><span style="font-size: large;">array literal (對，他不是叫 set literal):</span></p>
<pre>var favoriteGenres: Set&lt;String&gt; = ["Rock", "Classical", "Hip hop"]
var favoriteGenres: Set = ["Rock", "Classical", "Hip hop"]
</pre>
<p><span style="font-size: large;">(沒有指定 type Set 就會被當作 Arrary)</span></p>
<p><span style="font-size: large;">Set 不能用 subscript syntax 來存取 member，合理，因為 Set 沒有順序性。用 mySet.contains(item) 來判斷 item 是否存在於 mySet.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;"><b>Dictionary</b></span><br />
<span style="font-size: large;">initializer syntax:</span></p>
<pre>var namesOfIntegers = [Int: String]()
</pre>
<p><span style="font-size: large;">dictionary literal:</span></p>
<pre>var airports: [String: String] = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
var airports = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
</pre>
<p><span style="font-size: large;">存取用 subscript syntax。</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">跟 Python 比起來，Swift collections 都是中括號。</span><span style="font-size: large;">Swift 也有 Tuple (小括號)，用於 loop 的參數值，function 的 input/output 值等等，但不屬於 collection.</span></p>
<div><span style="font-size: large;"><br />
</span><span style="font-size: large;">蘋果官方 Swift 的教程 (go through an example)</span><br />
<a href="https://developer.apple.com/library/prerelease/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/" target="_blank" rel="noopener noreferrer"><span style="font-size: large;">https://developer.apple.com/library/prerelease/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/</span></a><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">蘋果官方的 App Distribution Guide</span><br />
<a href="https://developer.apple.com/library/prerelease/ios/documentation/IDEs/Conceptual/AppDistributionGuide/Introduction/Introduction.html" target="_blank" rel="noopener noreferrer"><span style="font-size: large;">https://developer.apple.com/library/prerelease/ios/documentation/IDEs/Conceptual/AppDistributionGuide/Introduction/Introduction.html</span></a></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yuyansoftware.com.tw/2015/10/swift-data-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Android NDK</title>
		<link>https://blog.yuyansoftware.com.tw/2013/04/android-ndk/</link>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Mon, 22 Apr 2013 14:26:00 +0000</pubDate>
				<category><![CDATA[軟體開發隨筆]]></category>
		<guid isPermaLink="false">http://test234.yuyansoftware.com.tw/2013/04/22/android-ndk/</guid>

					<description><![CDATA[OGRE Android uses Android NDK to build. Let&#39;s inves &#8230; ]]></description>
										<content:encoded><![CDATA[<p><span style="font-size: large;">OGRE Android uses Android NDK to build. Let&#39;s investigate somehow how Android NDK works.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">Objective:</span><br />
<span style="font-size: large;">1. Build the NDK development environment.</span><br />
<span style="font-size: large;">2. Experience the Android APP publishing process.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">Work log:</span><br />
<span style="font-size: large;">1. followed the nice link to build and run the <i><span style="color: #666666;">hello-jni</span></i> sample.</span><br />
<a href="http://www.ntu.edu.sg/home/ehchua/programming/android/Android_NDK.html"><span style="font-size: large;">http://www.ntu.edu.sg/home/ehchua/programming/android/Android_NDK.html</span></a><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">2. published the project on google play:</span><br />
<a href="https://play.google.com/store/apps/details?id=larry.myndkexperimentalproject&amp;feature=search_result#?t=W251bGwsMSwxLDEsImxhcnJ5Lm15bmRrZXhwZXJpbWVudGFscHJvamVjdCJd"><span style="font-size: large;">https://play.google.com/store/apps/details?id=larry.myndkexperimentalproject&amp;feature=search_result#?t=W251bGwsMSwxLDEsImxhcnJ5Lm15bmRrZXhwZXJpbWVudGFscHJvamVjdCJd</span></a><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">Note:</span><br />
<span style="font-size: large;">1. The sample is actually only C (not C++). I tried using C++, but the application crashed at run-time. The error was something like <i><span style="color: #666666;">JNI_OnLoad</span></i>&nbsp;was not found, the JNI C function was not implemented, etc. The following link is about the solution:</span><br />
<a href="http://cheng-min-i-taiwan.blogspot.tw/2011/08/java-native-interface-jni-android-c.html"><span style="font-size: large;">http://cheng-min-i-taiwan.blogspot.tw/2011/08/java-native-interface-jni-android-c.html</span></a><br />
<span style="font-size: large;">The issue is not easy so I leave it for future investigation.</span><br />
<span style="font-size: large;"><br />
</span><br />
<a name="more"></a><span style="font-size: large;">2. When to use NDK? Nice link:</span><br />
<a href="http://cheng-min-i-taiwan.blogspot.tw/2011/05/java-native-interface-jni.html"><span style="font-size: large;">http://cheng-min-i-taiwan.blogspot.tw/2011/05/java-native-interface-jni.html</span></a><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">The NDK interface is not easy to maintain (see the problem in note.1). Except game engines, the timings to use NDK should be just like the above link. But personally I doubt how much the benefit you get compared to the overhead you pay when implementing an algorithm using NDK, and I am still curious about when to use NDK in practice.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">The official web page:</span><br />
<a href="http://developer.android.com/tools/sdk/ndk/index.html"><span style="font-size: large;">http://developer.android.com/tools/sdk/ndk/index.html</span></a><br />
<span style="font-size: large;"><i>&#8220;using native code on Android generally does not result in a noticable performance improvement, but it always increases your app complexity. In general, you should only use the NDK if it is essential to your app&#8221;</i></span></p>
<p><span style="font-size: large;">3. OGRE Android building tutorial:</span><br />
<a href="http://www.ogre3d.org/tikiwiki/tiki-index.php?page=CMake+Quick+Start+Guide&amp;tikiversion=Android"><span style="font-size: large;">http://www.ogre3d.org/tikiwiki/tiki-index.php?page=CMake+Quick+Start+Guide&amp;tikiversion=Android</span></a><br />
<span style="font-size: large;">The sample was successfully built and run, but the details of the building steps are still unknown.</span></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>The role of C++ in Windows 8 application development</title>
		<link>https://blog.yuyansoftware.com.tw/2013/04/the-role-of-c-in-windows-8-application/</link>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Tue, 16 Apr 2013 16:06:00 +0000</pubDate>
				<category><![CDATA[軟體開發隨筆]]></category>
		<guid isPermaLink="false">http://test234.yuyansoftware.com.tw/2013/04/17/the-role-of-c-in-windows-8-application-development/</guid>

					<description><![CDATA[I have been&#160;interested in&#160;Windows 8 applicati &#8230; ]]></description>
										<content:encoded><![CDATA[<p><span style="font-size: large;">I have been&nbsp;interested in&nbsp;Windows 8 application development since it was announced. The following diagram includes all the methods&nbsp;regarding Windows 8 application development.</span><br />
<span style="font-size: large;">Ref.&nbsp;<a href="http://msdn.microsoft.com/zh-tw/hh976905.aspx">http://msdn.microsoft.com/zh-tw/hh976905.aspx</a></span></p>
<div style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-zKXq2cFPUjo/UeK6OGA_msI/AAAAAAAAAQc/N3o93rnBLRk/s1600/%E6%9C%AA%E5%91%BD%E5%90%8D3.png" style="margin-left: 1em; margin-right: 1em;"><span style="font-size: large;"><img decoding="async" border="0" src="https://1.bp.blogspot.com/-zKXq2cFPUjo/UeK6OGA_msI/AAAAAAAAAQc/N3o93rnBLRk/s1600/%E6%9C%AA%E5%91%BD%E5%90%8D3.png"></span></a></div>
<p><span style="font-size: large;"><br />
</span><span style="font-size: large;">Here is a nice article regarding using C++ to develop metro style app:</span><br />
<span style="font-size: large;"><a href="http://blogs.msdn.com/b/ericsk/archive/2012/05/02/metro-style-app-dev-using-cpp.aspx">http://blogs.msdn.com/b/ericsk/archive/2012/05/02/metro-style-app-dev-using-cpp.aspx</a></span></p>
<p><a name="more"></a><span style="font-size: large;">The C++ in metro style app development is actually called C++/CX. From wiki:</span><br />
<a href="http://en.wikipedia.org/wiki/C%2B%2B/CX"><span style="font-size: large;">http://en.wikipedia.org/wiki/C%2B%2B/CX</span></a><br />
<span style="font-size: large;">&#8220;The language extensions borrow syntax from C++/CLI but target the Windows Runtime and native code instead of the Common Language Runtimeand managed code.&#8221;</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">For me, C++/CX is so like C++/CLI. Since I have some experience in developing C++/CLI, and personally I don&#39;t prefer it. Therefore, I am&nbsp;conservative about C++/CX. Here are the pros and cons when using C++ in metro style app development.</span><br />
<span style="font-size: large;">Pros:</span><br />
<span style="font-size: large;">1. It&#39;s C++. It&#39;s somehow a general language for all programmers.</span><br />
<span style="font-size: large;">2. It can be easily integrated with <i>Boost</i> library, multimedia codecs, and other C++ libraries.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">Cons:</span><br />
<span style="font-size: large;">1. C++/CX is not perfectly the same as C++ and it&#39;s not popular, while, say, C++, JAVA, and C# are popular.</span><br />
<span style="font-size: large;">2. (At least for me) It&#39;s&nbsp;ambiguous. Ambiguity comes from things are alike, but one has slight differences from another.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">Then, how about the huge number of MFC softwares which have been existing for many many years? They still can run on Windows 8 desktop mode.</span><br />
<span style="font-size: large;">Since now we have WinRT and Win32 even in the same computer, is there any cross-platform issue? Yes, there is. Here is a Microsoft nice article:</span><br />
<a href="http://msdn.microsoft.com/zh-tw/magazine/jj651574.aspx"><span style="font-size: large;">http://msdn.microsoft.com/zh-tw/magazine/jj651574.aspx</span></a><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">At this time I won&#39;t say it&#39;s a cross-platform issue. In practice, I think the metro project and the desktop project are going to be different two, with largely different UI. At most, they use shared modules, but personally I don&#39;t think it&#39;s a cross-platform concept when we are using C++ to develop. On the other hand, if you really plan to do a cross-platform project (including Android and IOS), html/javascript is the best choice. But again, what to do depends on the project requirements and what is already there.</span></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Google C++ Testing Framework</title>
		<link>https://blog.yuyansoftware.com.tw/2013/04/google-c-testing-framework/</link>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Sat, 13 Apr 2013 07:34:00 +0000</pubDate>
				<category><![CDATA[軟體開發隨筆]]></category>
		<guid isPermaLink="false">http://test234.yuyansoftware.com.tw/2013/04/13/google-c-testing-framework/</guid>

					<description><![CDATA[I have heard this testing framework so many times, so I &#8230; ]]></description>
										<content:encoded><![CDATA[<p><span style="font-size: large;">I have heard this testing framework so many times, so I decided to investigate it somehow.</span><br />
<span style="font-size: large;">The official wiki link:</span><br />
<a href="https://code.google.com/p/googletest/w/list"><span style="font-size: large;">https://code.google.com/p/googletest/w/list</span></a><br />
<span style="font-size: large;">v1_6_Primer</span><br />
<a href="https://code.google.com/p/googletest/wiki/V1_6_Primer"><span style="font-size: large;">https://code.google.com/p/googletest/wiki/V1_6_Primer</span></a><br />
<span style="font-size: large;">v1_6_AdvancedGuide</span><br />
<a href="https://code.google.com/p/googletest/wiki/V1_6_AdvancedGuide"><span style="font-size: large;">https://code.google.com/p/googletest/wiki/V1_6_AdvancedGuide</span></a><br />
<span style="font-size: large;"><br />
</span><u><span style="font-size: large;">Simple Test</span></u></p>
<pre>TEST(test_case_name, test_name) 
{
  //... test body ...
}
</pre>
<p><span style="font-size: large;"><br />
</span><u><span style="font-size: large;">Test Fixture</span></u></p>
<pre>TEST_F(test_case_name, test_name) 
{
  //... test body ...
}
</pre>
<p><span style="font-size: large;">The above <i><span style="color: #666666;">test_case_name</span></i> must be your test fixture class, which must inherit from <i><span style="color: #666666;">testing::Test</span></i>. You can optionally override the functions:&nbsp;<i><span style="color: #666666;">SetUp</span></i> and <i><span style="color: #666666;">TearDown</span></i>. In a <i><span style="color: #666666;">TEST_F</span></i>, the flow is like:</span><br />
<span style="font-size: large;">1. the test fixture class constructs.</span><br />
<span style="font-size: large;">2. its <i><span style="color: #666666;">SetUp</span></i> function is called (if there is).</span><br />
<span style="font-size: large;">3. do your arrangement and assertion works.</span><br />
<span style="font-size: large;">4. the <i><span style="color: #666666;">TearDown</span></i> function is called (if there is).</span><br />
<span style="font-size: large;">5. the test fixture class destructs.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">The above a, b, d, e are automatically done, which means you don&#39;t see it in a <i><span style="color: #666666;">TEST_F</span></i>. However, step c is the tester&#39;s job.</span><br />
<span style="font-size: large;"><br />
</span><br />
<a name="more"></a><span style="font-size: large;"><u>Typed Test</u></span><br />
<span style="font-size: large;">1. Implement a template fixture class (a template class inherits from&nbsp;<i><span style="color: #666666;">testing::Test</span></i>).</span><br />
<span style="font-size: large;">2. Use&nbsp;<i><span style="color: #666666;">TYPED_TEST_CASE</span></i> to define the data types that will run as the template argument of the template fixture class.</span><br />
<span style="font-size: large;">3. Use&nbsp;<i><span style="color: #666666;">TYPED_TEST</span></i> to start a test case. Note the 1st argument should be the template fixture class. Besides, the test case will run N times depending on how many data types you define in the above step 2.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;"><br />
</span><u><span style="font-size: large;">Type-Parameterized Test</span></u><br />
<span style="font-size: large;">1. Implement a template fixture class (a template class inherits from&nbsp;<i><span style="color: #666666;">testing::Test</span></i>).</span><br />
<span style="font-size: large;">2. Use&nbsp;<i><span style="color: #666666;">TYPED_TEST_CASE_P</span></i> to inform the framework that you will have a test case.</span><br />
<span style="font-size: large;">3. Use&nbsp;<i><span style="color: #666666;">TYPED_TEST_P</span></i>&nbsp;to start a test case. Note until now the framework has no idea what data types to run in the test case.</span><br />
<span style="font-size: large;">4. An extra step: use&nbsp;<i><span style="color: #666666;">REGISTER_TYPED_TEST_CASE_P</span></i> to register the test case and all the tests under it.</span><br />
<span style="font-size: large;">5. Finally, tell the framework what data types to run in the test case by using&nbsp;<i><span style="color: #666666;">INSTANTIATE_TYPED_TEST_CASE_P</span></i> (see v1_6_AdvancedGuide for the usage).</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">By the test method, the same test case can have different sets of testing data types.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;"><br />
</span><u><span style="font-size: large;">Value-Parameterized Test</span></u><br />
<span style="font-size: large;">1.&nbsp;Implement a fixture class (inherits from&nbsp;<i><span style="color: #666666;">testing::TestWithParam&lt;T&gt;</span>,&nbsp;</i>and <i>T</i> must be assigned).</span></p>
<div><span style="font-size: large;">2. When implementing the fixture class, you can override the <i><span style="color: #666666;">SetUp</span></i> and <i><span style="color: #666666;">TearDown</span></i> functions, and use&nbsp;<i><span style="color: #666666;">GetParam</span></i> to get the test parameters (which will be set later but with the data type <i>T</i> in the above step 1).</span></div>
<div><span style="font-size: large;">3. Use&nbsp;<i><span style="color: #666666;">TEST_P</span></i>&nbsp;to start a test case. Note until now the framework has no idea what data values to run in the test case.</span></div>
<div><span style="font-size: large;">4. Tell the framework what data values to run in the test case by using&nbsp;<i><span style="color: #666666;">INSTANTIATE_TEST_CASE_P</span> </i>(see v1_6_AdvancedGuide for the usage). The 3rd argument can be:</span><br />
<span style="font-size: large;">Range</span><br />
<span style="font-size: large;">Values</span><br />
<span style="font-size: large;">ValuesIn</span><br />
<span style="font-size: large;">Bool</span><br />
<span style="font-size: large;">Combine</span></div>
<div><span style="font-size: large;"><br />
</span><span style="font-size: large;">,which generate different sets of test parameters. The same as&nbsp;Type-Parameterized Test, this test method instantiates a test case AFTER the fixture class.</span></div>
<div><span style="font-size: large;"><br />
</span></div>
<div><span style="font-size: large;"><br />
</span></div>
<div><u><span style="font-size: large;">Define your custom event listeners</span></u><br />
<span style="font-size: large;">1.&nbsp;Implement an event listener class (inherits from<span style="color: #666666;">&nbsp;<i>testing::TestEventListener</i></span> or&nbsp;<i><span style="color: #666666;">testing::EmptyTestEventListener</span></i>.)</span><br />
<span style="font-size: large;">2. Register your event listener class to the framework, like: (from Google provided sample <i><span style="color: #666666;">sample9_unittest.cc</span></i>)</span></div>
<pre>TestEventListeners&amp; listeners = unit_test.listeners();
delete listeners.Release(listeners.default_result_printer());
listeners.Append(new TersePrinter);
</pre>
<p><span style="font-size: large;">Then you can have your custom event listener when, say, a test starts/ends, assertion fails/succeeds, etc.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">Note that&nbsp;<i><span style="color: #666666;">sample10_unittest.cc</span></i> demonstrates a nice way for memory leak check, where each class in your system should keep the creating count in such class, and the client side also keeps a count. Also note this is just one way to prevent from memory leak.</span></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Class Diagram &#038; Sequence Diagram</title>
		<link>https://blog.yuyansoftware.com.tw/2012/09/class-diagram-sequence-diagram/</link>
					<comments>https://blog.yuyansoftware.com.tw/2012/09/class-diagram-sequence-diagram/#respond</comments>
		
		<dc:creator><![CDATA[Larry]]></dc:creator>
		<pubDate>Sun, 16 Sep 2012 04:40:00 +0000</pubDate>
				<category><![CDATA[軟體開發隨筆]]></category>
		<guid isPermaLink="false">http://test234.yuyansoftware.com.tw/2012/09/16/class-diagram-sequence-diagram/</guid>

					<description><![CDATA[要了解 Class Diagram 可以先了解 UML (Unified Modeling Language). UML 是由 “Object Management Group” 所創造並管理。目前 (20120916) 最新的的版本是 UML 2.4.1]]></description>
										<content:encoded><![CDATA[<p><span style="font-size: large;">1. Background:</span><br />
<span style="font-size: large;">要了解 Class Diagram 可以先了解 UML (Unified Modeling Language).&nbsp;UML 是由 &#8220;Object Management Group&#8221; 所創造並管理 [1]. 目前(20120916)最新的的版本是 UML 2.4.1 [2].</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">UML 2.4.1 包含了非常多種塑模圖表, 主要分成三類. 而本篇的主題 Class Diagram 則是歸在第一類.</span><br />
<span style="font-size: large;">&nbsp; &nbsp; a. Structure:</span><br />
<span style="font-size: large;">&nbsp; &nbsp; &nbsp; &nbsp; Ex: Class Diagram, etc.</span><br />
<span style="font-size: large;">&nbsp; &nbsp; b. Behavior</span><br />
<span style="font-size: large;">&nbsp; &nbsp; &nbsp; &nbsp; Ex: Sequence Diagram, State Diagram, Use Case Diagram, etc.</span><br />
<span style="font-size: large;">&nbsp; &nbsp; c. Supplement</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">2. Class Diagram 線圖的定義:</span><br />
<span style="font-size: large;">IBM 的這個網頁提供了很清楚而且 formal 的說明 [3].</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">3. Class Diagram 的使用:</span><br />
<span style="font-size: large;">MSDN 的這個網頁 [4] 簡述了 Class Diagram 的使用時機以及 Visual Studio 對 Class Diagram 的支援.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;">4. Sequence Diagram:</span><br />
<span style="font-size: large;">IBM 的這個網頁提供了很清楚而且 formal 的說明 [5]. 但要注意的是, 線圖的最終目的是要讓自己及其他 programmer 了解架構, 行為. 使用過度複雜的線圖個人認為反而阻礙開發, 阻礙理解.</span><br />
<span style="font-size: large;"><br />
</span><span style="font-size: large;"><br />
</span><span style="font-size: large;">References</span><br />
<span style="font-size: large;">[1]&nbsp;<a href="http://en.wikipedia.org/wiki/Unified_Modeling_Language" target="_blank" rel="noopener noreferrer">http://en.wikipedia.org/wiki/Unified_Modeling_Language</a></span><br />
<span style="font-size: large;">[2]&nbsp;<a href="http://www.omg.org/spec/UML/" target="_blank" rel="noopener noreferrer">http://www.omg.org/spec/UML/</a></span><br />
<span style="font-size: large;">[3]&nbsp;<a href="http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/" target="_blank" rel="noopener noreferrer">http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/</a></span><br />
<span style="font-size: large;">[4]&nbsp;<a href="http://msdn.microsoft.com/en-us/library/33864ckt.aspx" target="_blank" rel="noopener noreferrer">http://msdn.microsoft.com/en-us/library/33864ckt.aspx</a></span><br />
<span style="font-size: large;">[5]&nbsp;<a href="http://www.ibm.com/developerworks/rational/library/3101.html" target="_blank" rel="noopener noreferrer">http://www.ibm.com/developerworks/rational/library/3101.html</a></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yuyansoftware.com.tw/2012/09/class-diagram-sequence-diagram/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
