假如今天要讀取路徑為Resources/test.xml 的XML, 內容如下:
For example, the XML data we want read as below, the path is "Resources/test.xml":
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ROOT>
<table wave="1" level="1" name="aaa"/>
<table wave="2" level="1" name="bbb"/>
</ROOT>
我們有兩種簡便讀取的方法:
We have 2 simple ways can use:
2014年8月28日 星期四
[Unity][C#]2 simple ways of load the data form XML // 兩種簡便讀取XML資料的方法
標籤:
C#,
Unity,
windows phone,
XML
I like thinking,
I like creating,
I have many weird ideals,
I like challenging and be tormented with limitless debugging.
The most important, I'm unable to resist the sense of accomplishment when complete a program after hard work.
So I coding.
2014年4月4日 星期五
[CleanCode]Adjust your if-else//整頓你的if-else
判斷流程複雜時, 我們會需要很多層if-else在程式裡, 最後很容易變成如下又肥又醜的模樣:
We need many if-else struct when the flow is complicated, then the struct of program will become big and ugly, as below:
真是讓人看得眼花撩亂, 不是嗎?
These make us dazzle, isn't it?
其實我們可以換種寫法:
Actually, we can change a way:
程式運作的邏輯一樣, 但看起來是不是好讀多了呢?
The logic program operating is same, but it become much good to read.
這種技巧是把做完可以直接return的判斷式獨立出來; 利用"return後下方的程式碼不會執行"的特性, 使程式的結構脫離if-else必須一層包一層的窘境
This way is separating the statement which process return when operating done; the code struct can be breaking away the dilemma of if-else layer packet layer, by using the feature of "program will not execute the codes after return".
如此, 我們可以在看多層判斷式時不必再辛苦的對照程式碼在哪一層判斷式 , 大大增加了程式的可讀性
So we don't need to look for codes in the multi-layer predicate, it increases the program's readability.
We need many if-else struct when the flow is complicated, then the struct of program will become big and ugly, as below:
if(A)
{
do A-1...
if(B)
{
do B-1...
if(C)
{
do C-1...
}else{
do C-2...
return...
}
}else{
do B-2...
return...
}
}else{
do A-2...
return...
}
真是讓人看得眼花撩亂, 不是嗎?
These make us dazzle, isn't it?
其實我們可以換種寫法:
Actually, we can change a way:
if(!A)
{
do A-2...
return...
}
do A-1...
if(!B)
{
do B-2...
return....
}
do B-1...
if(!C)
{
do C-2...
return...
}
do C-1...
程式運作的邏輯一樣, 但看起來是不是好讀多了呢?
The logic program operating is same, but it become much good to read.
這種技巧是把做完可以直接return的判斷式獨立出來; 利用"return後下方的程式碼不會執行"的特性, 使程式的結構脫離if-else必須一層包一層的窘境
This way is separating the statement which process return when operating done; the code struct can be breaking away the dilemma of if-else layer packet layer, by using the feature of "program will not execute the codes after return".
如此, 我們可以在看多層判斷式時不必再辛苦的對照程式碼在哪一層判斷式 , 大大增加了程式的可讀性
So we don't need to look for codes in the multi-layer predicate, it increases the program's readability.
=======================
希望這對你有幫助,歡迎提供建議
Hope this help you, welcome to advice me.
標籤:
CleanCode
I like thinking,
I like creating,
I have many weird ideals,
I like challenging and be tormented with limitless debugging.
The most important, I'm unable to resist the sense of accomplishment when complete a program after hard work.
So I coding.
2013年11月2日 星期六
[Java]Rlease--G Clock1.1
我為G Clock增加了一些功能並釋出1.1版
I increase some functions of G Clock and release the version to 1.1
Update Items:
I increase some functions of G Clock and release the version to 1.1
Update Items:
1. Increase a ComboBox, user could select 2 models to set alarm:
1.Countdown
2.Timing
2.Increase input columns of "Now Plan" and "Next
Plan", user could input their simple plan for remain.
3.Increase a button for quickly update "Next Plan" to "Now
Plan".
Codes:
The codes of Timing model as below:
標籤:
java
I like thinking,
I like creating,
I have many weird ideals,
I like challenging and be tormented with limitless debugging.
The most important, I'm unable to resist the sense of accomplishment when complete a program after hard work.
So I coding.
2013年10月20日 星期日
[C#]About the way of trace the value of Rectangle.Fill //關於追蹤Rectangle.Fill值的方法
我最近在研究用C#跟XAML開發 Windows phone APP, 不過遇到了些困難, 其中一個就是我找不到可以直接追蹤Rectangle.Fill值的方法
I study of Windows phone APP development with C# and XAML nearly, but I experience some troubles, one of them is we have no way to trace to the value of Rectangle.Fill immediately.
我能理解設計者必須站在高處為開發者考慮通用的功能;矩形不只能填充單一色彩, 也能填充漸層甚至更複雜的圖案, 所以要設計一個參數或者方法去得顏色的值是很困難的
I can understand that designer need concern the general function for developers; the rectangle not only could be filled with one color, but also could be filled with linear gradient or even more complicated picture, so it's hard to design a property or a method for show the value of color.
不過我的要求其實很單純, 我只是要取得Rectangle.Fill的值, 我們只能給Rectangle.Fill設一種顏色對吧?不需要複雜的方法去比較每一個像素, 只需要一個參數去儲存色碼, 為什麼我們沒有方法去追蹤Fill的值呢?
I study of Windows phone APP development with C# and XAML nearly, but I experience some troubles, one of them is we have no way to trace to the value of Rectangle.Fill immediately.
我能理解設計者必須站在高處為開發者考慮通用的功能;矩形不只能填充單一色彩, 也能填充漸層甚至更複雜的圖案, 所以要設計一個參數或者方法去得顏色的值是很困難的
I can understand that designer need concern the general function for developers; the rectangle not only could be filled with one color, but also could be filled with linear gradient or even more complicated picture, so it's hard to design a property or a method for show the value of color.
不過我的要求其實很單純, 我只是要取得Rectangle.Fill的值, 我們只能給Rectangle.Fill設一種顏色對吧?不需要複雜的方法去比較每一個像素, 只需要一個參數去儲存色碼, 為什麼我們沒有方法去追蹤Fill的值呢?
標籤:
C#,
windows phone
I like thinking,
I like creating,
I have many weird ideals,
I like challenging and be tormented with limitless debugging.
The most important, I'm unable to resist the sense of accomplishment when complete a program after hard work.
So I coding.
2013年10月8日 星期二
[Java]Alarm Clock with Multi-Thread //多執行緒實做鬧鐘
Interface
1. Time column: Show the time now.
2. Countdown column: For input the time of
countdown number.
3. Button: For start/stop countdown or stop
alarm.
標籤:
java
I like thinking,
I like creating,
I have many weird ideals,
I like challenging and be tormented with limitless debugging.
The most important, I'm unable to resist the sense of accomplishment when complete a program after hard work.
So I coding.
訂閱:
文章 (Atom)


