源自:https://www.facebook.com/weshouldlearn/posts/5670960566

【每天都要問孩子的四個問題】看似簡單的問題,背後蘊涵著豐富的含義和關愛。

一、學校有什麼好事發生嗎?
調查女兒的價值觀,了解她心裡面覺得哪些是好的,哪些是不好的。

二、今天你有什麼好的表現?
激勵女兒,增加她的自信心。

三、今天有什麼好收穫嗎?
讓她確認一下具體學到了什麼。

四、有什麼需要爸爸的幫助嗎?
一是表示對孩子的關心,二是學習是你自己的事。

給朋友正面能量請【分享】

michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

嘸蝦米特色和優勢就是它只用到26個英文字母按鍵,中英打可以一起練習
不使用簡根的話,每個字最多4碼, 按筆劃順序的前三碼和最後一碼
據官方說法:嘸蝦米平均輸入碼數2.2碼 ,選字率低於0.3% 參考 研究報告

以下是學習心得

1.英打練習:至少要20字以上/分鐘
   官方英打練習測驗  http://boshiamy.com/LiuCAI/english.html
   英打練習(可紀錄進度): http://www.ratatype.com/
2.字棖:最容易有問題的是:搖頭擺尾、其他(特硃字)
以下練習時一定會有些字 容昜猜錯,這時候請拿小抄 (字根總表) ,不會的馬上查,記得最快!

形: 形狀聯想 , e.g.  A:寸、L:乚
音: 發音聯想, e.g.  L:立、M:目
義:英文/數字等聯想,e.g. R:二、F:四、H:心
搖頭擺尾:形音義的 相似形:F(匸、亡、匕)、E(山、爪、屯)
其他:特硃記法 e.g. K(黃)、I(欠)、P(至)  參考字根總表

官方字根總表
undefined 


3.取碼規則
  由外而內:犬→ A(、) + D(大) +N(捺一撇)
  書寫順序:碼→ L(丆) + O(口) + M (馬) + F(四點火)
  截長補短:截長→前三碼後,再取最後一筆劃→簿:Z(竹) + W(氺) + A(、) + A(寸,跳取最後一碼)
                    補短→若取完只有一到二碼,則要再補一碼:輔根(最後一劃的形狀)→大:D + N(補捺一撇)                                        
 大根先取: 數:→M(婁的上半部、簡体為米,故取M) + G(女) + P(攵) → M是大根筆劃多,先取
                   餘:X(食) + A(金) + T(木)→ X是大根筆劃多,先取
容錯拆碼:一個字可以有多種拆法,不同筆劃或簡根

4.練習

  官方web版練習測驗 http://boshiamy.com/LiuCAI/root.html
  此版練習程式有錯字重複練習功能(dos版LiuEasyLearn沒有)
  1.請先練習"字根":依序形、音、 義(數字、英文)、搖頭擺尾、其他‧‧‧再開始練習單字
  2.再練練習單字:依序形、形音、形音數、形音數英、形音義…
  3.可自行剪貼文章 到自選文章,用自己熟悉的文章貼近真實使用情況
     也比較有成就感--自選文章: http://boshiamy.com/LiuCAI/article_custom.html 


5.查碼工具
1.輸入 ' ;  進入注音模式,打出注音可顯示所有無蝦米的,所有拆碼包含標準碼及簡碼
2.輸入 '     進入同音字模式,遇到不會拆碼的字可以先輸入同音字,顯示出所有同音字後再選字
3.線上查碼:http://boshiamy.com/LiuCAI/main3.html

小記:

1.每天練習一小時:一週後約可到30字/分鐘
2.難度:
   形:★    (圖像還是比較好理解,如:A (亼),只是要注意大根要先取, 義 :B(八) + K(王)+ 我(I) )
   音:★★★ (念得出來的就用音? 念的出但有更筆畫更少的字根,還是要以該字根為主,如: 白 不能拆成B 而要拆成PD,貝 不能拆成B, 要拆成MB)
   義(數字、英文):★      (1~10好記,H(心),K(斤),手(H)...)
   搖頭擺尾:★★★   由以上的形音義的變形太多,容易誤解,須多加練習
   利用錯字重複練習功能加強
3.字根練熟再練單字(忘記馬上看小抄)
4.官方建議25字/分鐘以上才可練簡根?
   只要你拆碼已經完全理解吸收
   其實簡根可以馬上使用!官方簡根快打 http://boshiamy.com/LiuCAI/main2.html
    通常此時你的速度也差不多接近30字/分鐘

 


官方一碼字表:(所有權屬無蝦米官方)



官方二碼字表:(所有權屬無蝦米官方)





  














































michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

最近開始使用AngularJS+ASP.NET WebAPI做專案
restful webapi 雖定義了GET/POST/PUT/DELETE 但並無標準web service 的wdsl 可以產生xml 文件
此時需安裝套件以自動產生help page,開發筆記如下:

1.使用nuget安裝套件helppage

Package Manager Console> Install-Package Microsoft.AspNet.WebApi.HelpPage

2.使用/// 快速鍵,將controller之action 等級加上說明

/// <summary>
/// 刪除外撥主檔
/// </summary>
/// <param name="outboundIdRoot"></param>
/// <returns></returns>
public bool Delete(string outboundIdRoot)
{
    OutboundProgramBLL outboundProgramBLL = new OutboundProgramBLL();
    return outboundProgramBLL.Delete(outboundIdRoot); ;
}

3.專案屬性
輸出:XML文件檔案:App_Data\Document.XML

4.設定使用Document.XML
修改~Area/HelpPage/App_Start/HelpPageConfig.cs           

  public static void Register(HttpConfiguration config)
        {
        //// Uncomment the following to use the documentation from XML documentation file.
            config.SetDocumentationProvider(
new XmlDocumentationProvider(
HttpContext.Current.Server.MapPath("~/App_Data/Document.XML")));
            //...
            //...
        }


5.F6重新編譯 專案

7.使用http://xxxxxx/help  查看helppage


 










michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

家中有一台synology nas  內建的是 MariaDB 5.5.43 (mysql 分支)
另外有一fedora linux 的MySQL 5.1  
最近嘗試將兩部MySQL 表兄弟做replication,以下為實戰筆記....

區分以下段落
0.replication概要
1.環境說明
2.設定mater
3.設定slave
4.異常處理

0.mysql replication 官方說法
參考: http://dev.mysql.com/doc/refman/5.0/en/replication...

0.1 mysql的replication 單向複寫
可設定一個master,多個slave,靠啟用binary log來將異動資料由master送給slave
 

0.2 Scale out ,分散讀寫不同作業,提高效能

 

0.3 master異常時,切換到slave維持運作
mysql>change master to ...   可將master 指到的slave1
正常情況
 

異常時切換master
 



1.環境說明
master: MySQL 5.1 on fedora linux , ip=master.mydomain.com
slave : MariaDB 5.5 on Synology Nas (mysql 分支) , dns=slave.mydomain.com ,ip=slave_db_ip_address

2.設定master 
2.1.edit my.cnf@master db   (/etc/my.cnf)
#master config
[mysqld]
server-id=9419601
log_bin=mysql-bin
log_error=mysql-bin.err
binlog_do_db=db1
binlog_do_db=db2
binlog_do_db=db3

2.2 create replication user @master db

CREATE USER 'rep_user'@'slave_db_ip_address' IDENTIFIED BY  'rep_user_password';

GRANT REPLICATION SLAVE , REPLICATION CLIENT ON * . * TO  'rep_user'@'slave_db_ip_address' IDENTIFIED BY  'rep_user_password';

2.3 restart@master db

2.4 顯示master狀態@master db
mysql>show master status;

變數
File mysql-bin.000009
Position 11724
Binlog_Do_DB db1,db2,db3
Binlog_Ignore_DB

2.5 顯示目前連線之slave host@master db
mysql>show slave hosts;

Server_id Host Port Rpl_recovery_rank Master_id
1444825616 slave.mydomain.com 3306 0 9419601


3.設定slave

3.1 edit  my.cnf@slave db   (/etc/mysql/my.cnf)

[mysqld]
server-id=1444822168                #由phpMyadmin之Replication頁籤/slave 取得
report-host=slave.mydomain.com  #此hostname 將回報給master 
slave-skip-errors = all                 #避免發生錯誤時,中斷replication

3.2 restart@slave db
/usr/syno/bin/synopkg restart MariaDB 

3.3 設定mater@slave db

CHANGE MASTER TO

  MASTER_HOST='master.mydomain.com',
  MASTER_USER='rep_user',

  MASTER_PASSWORD='rep_user_password',
 MASTER_PORT=3306

3.4 顯示slave 狀態@slave db
mysql>show slave status;

變數
Slave_IO_State Waiting for master to send event
Master_Host master.myadomain.com
Master_User rep_user
Master_Port 3306
Connect_Retry 60
Master_Log_File mysql-bin.000009
Read_Master_Log_Pos 11450
Relay_Log_File mysqld-relay-bin.000013
Relay_Log_Pos 8157
Relay_Master_Log_File mysql-bin.000009
Slave_IO_Running Yes
Slave_SQL_Running Yes
Replicate_Do_DB
Replicate_Ignore_DB
Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
Last_Errno 0
Last_Error
Skip_Counter 0
Exec_Master_Log_Pos 11450
Relay_Log_Space 8452
Until_Condition None
Until_Log_File
Until_Log_Pos 0
Master_SSL_Allowed No
Master_SSL_CA_File
Master_SSL_CA_Path
Master_SSL_Cert
Master_SSL_Cipher
Master_SSL_Key
Seconds_Behind_Master 0


4.replication異常停止 處理方法
4.1 顯示master 狀態@master db
mysql>show master status;
紀錄File 及Position

變數
File mysql-bin.000009
Position 11724


4.2 重設master_log_file 及master_log_pos @slave db
mysql>change master to 
master_host='master.mydomain.com',
 master_user='rep_user', 
 master_password='rep_user_password', 
 master_port=3306, 
 master_log_file='mysql-bin.000009', 
 master_log_pos=11724 ;






  





michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

今年的Techdays 2015 Taiwan大會影片
已經於channel9 上傳

https://channel9.msdn.com/Events/TechDays/TechDays-Taiwan-2015


1.專案管理 

尋找不用加班的 15 種方法

https://channel9.msdn.com/Events/TechDays/TechDays-Taiwan-2015/OFC205


2.asp.net

ASP.NET 5 開發攻略

https://channel9.msdn.com/Events/TechDays/TechDays-Taiwan-2015/DEV305

3.C#

.NET Framework 技術架構發展與 C# 6.0

https://channel9.msdn.com/Events/TechDays/TechDays...

4.敏捷開發

實現 End to End 的雲端敏捷開發流程


https://channel9.msdn.com/Events/TechDays/TechDays...

5.跨平台開發

C#. 跨界 X 跨平台.Visual Studio & Xamarin 開發

https://channel9.msdn.com/Events/TechDays/TechDays...




michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

參考:https://channel9.msdn.com/Events/TechDays/TechDays...

TechDays 2015 之 保哥-ASP.NET 5 開發攻略

1.安裝node.js
2.npm install -g yo   (安裝套件管理工具 yeoman之全域套件)
3.npm install -g generator-aspnet   (安裝aspnet 站台產生套件,類似express)
4.yo aspnet    (選擇WebApplication,並輸入應用程式目錄名稱aspnet5, yo會產生範本程式碼)

2.建置
2.1 cd aspnet5 
2.2  dnu restore   (還元套件,須先安裝aspnet 5 , 參考: http://docs.asp.net/en/latest/getting-started/inst...)
2.3 dnu build

3.開發:
3.1  code .   (對目前資料夾, 使用Visual Studio Code 進行開發)
3.2 或使用VS2015 開起專案檔aspnet5/project.json 進行開發建置
3.3 dnx web  (啟動站台http://localhost:5000)











michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

文章出處: http://www.enterpriseappstoday.com/data-management/10-database-design-best-practices.html



Posted July 15, 2014By Ann All     Feedback

A well-designed database makes it easier to derive value from enterprise data. We asked three experts for their top database design tips.

With enterprises looking for new ways to use data to gain competitive advantage, database design is now more important than ever. Here are some best practices that will result in a well-designed database.

Focus on the data, not the application

"Applications come and go, but data is forever," said Justin Cave, lead database consultant at Distributed Database Consulting, noting that he frequently sees programmers designing a database to cater to a specific application without considering future data needs. While they are often under pressure to deliver a database in a relatively short period of time, Cave said taking design shortcuts to help meet a deadline can make it much tougher to add new functionality in the future.

"If you properly design a database upfront, it is going to work for everybody. If you skip some functionality because 'we don't really need that,' you can count on someone needing it in the future," he said.

Leverage the power of your database

Too many programmers "treat databases like a data dump or a black box," Cave said, and choose to build database-independent applications. While there are instances where this is appropriate, it generally is not the best approach. "When you are not using the power of the database, you end up making things less efficient and harder to maintain," he said.

Utilizing the database makes it relatively easy to reuse design elements and add functionality. "But if everything is built into the application, you'll have to rebuild validation and a lot of the logic and you'll never get the same information," he said.

Include DBAs in the design phase

"There are so many ways that data gets used, it's hard for someone whose task is to 'build X' to envision that," Cave said, adding that it's not uncommon for developers to wait until the final stages of development to interact with database administrators. The result may be a lack of attention to details important to DBAs, such as naming conventions which make it easy to identify objects contained in the database. Given that DBAs may not have much time to spare to work with developers, Cave suggested it's a good idea for developers to "learn to think like a DBA."

Use data models

Despite widespread agreement that software engineering is important,many programmers forego data models, said Michael Blaha, a partner at Modelsoft Consulting and author of seven books including "Object-Oriented Modeling and Design." Noting that "data is the memory of an enterprise," he said, "Code is important, but replaceable -- an organization can always rewrite an app or purchase a new app. There is no excuse for not constructing at least a summary data model."

Consider different data interaction strategies

Many developers lack imagination in how applications can interact with a database, Blaha said. They may choose to use a database layer, hiding the database with programming objects that make database data indistinguishable from in-memory data. While this is a viable strategy, it has limitations.

"There are additional data interaction strategies," Blaha said. "For example, dedicated methods can encapsulate data access. Some methods can be written as stored procedures. Others can be written in programming code. The remaining programming logic accesses the database via these special methods."

Mobile Customer Care: It's More than Hype
 

Reuse good ideas

Rather than "obsessing on use cases" and trying to capture requirements from scratch, Blaha said developers can reuse ideas that have worked well in the past.

"For example, I often reverse engineer databases -- databases of an application to be replaced as well as databases of related applications," he said. "These existing databases often do not have an available data model. But a data model is implicit in the database schema and can be at least partially extracted with database reverse engineering techniques."

Another good example of reuse is incorporating data patterns, Blaha said, noting that one of his books, "Patterns of Data Modeling," explains many data patterns. "There are tried-and-true data representations that often occur and need not be recreated from scratch."

Index foreign database keys

Every foreign key in a database should be covered by an index, Blaha said. While some foreign keys are covered by implicit indexes that are created as a side effect of primary and alternate key definitions, developers should create an explicit index for the other foreign keys, he explained.

"Database queries often traverse from a foreign key to its primary key," Blaha said. "The resulting joins are efficient if primary keys are defined and every foreign key has an index. Just one missing index can degrade query performance by several orders of magnitude. It's hard to predict the traversals that might occur."

Pick database keys that support partitioning

Even if you're not planning on partitioning now, the application will likely need to evolve to support it at some point. Bryn Rhodes, co-owner and software architect for Database Consulting Group, said selection of a key type that easily supports partitioning can mean the difference between a smooth transition and a difficult upgrade.

Model with multiple perspectives

Optimal structures for one use case are often different than for another, especially when considering access paths to data. Make sure you take multiple perspectives into account so you find these potential issues early, Rhodes said, and build structures that enable data access in various ways.

Don't ignore the data access layer

When modeling the structures, be sure to consider that everything you build is going to have to be consumed by a data access layer at some point. Avoid using proprietary extensions to SQL unless there is a very good reason to do so. And if you must use proprietary extensions, try to provide some insulation for them.

Ann All is the editor of Enterprise Apps Today and eSecurity Planet. She has covered business and technology for more than a decade, writing about everything from business intelligence to virtualization.

michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

VCE Exam Sumulators 這個工具實在對準備認證的人來說太好用了
搭配http://examsforall.com/ 一堆網友熱騰騰的BrianDump
http://www.examcollection.com/  (之前使用examcollection,但他的*.vce 有加密,目前不推薦使用)


Required:

1.VCE模擬試題工具

Avanset VCE Exam Simulators

下載網址:http://1drv.ms/1zmm8YK


2.模擬試題 建議使用:http://examsforall.com/    (請不要用examcollection.com的考題, 他會加密,逼你使用最新版的vce)

Step:
1.模擬考試
   執行: VCE Player(player.exe)
   Add 加入考題(*.vce)
   

2.若要將考題列印出來,可用目錄內的designer.exe(VCE Designer)

 選擇列印到 Microsoft XPS document Writer or 其它 類似PDF Creator 的虛擬印表機

本次目標
MCSD Web Application
70-480  Programming in HTML5 with JavaScript and CSS3  
http://examsforall.com/exams/microsoft/70-480/

70-486 Developing ASP.NET MVC 4 Web Applications
http://examsforall.com/exams/microsoft/70-486/

70-487 Developing Windows Azure and Web Services
http://examsforall.com/exams/microsoft/70-487/
 

 

michaelfang 發表在 痞客邦 PIXNET 留言(6) 人氣()

第一次參加阿甘盃
參加人員:威益哥,warren,michael
本次沒有練習超過10km,成績乏善可陳
還好沒超過03:30 一路上 苦撐
這天有點陰雨,本來全家都要一起來參加~只好作罷
獎牌不錯,毛巾就差了點,好小條喔...









這種成績關門 能看嗎? 不過比富邦好一點...:p
















michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

幫好友 阿畢寫的
附贈了電筒的功能~
https://play.google.com/store/apps/details?id=tw.wii.app

server端:
   json輸出中文部分,先urlencode,json_encode後再urldecode
   避免產生不可閱讀之unicode編碼

app端:     

1.使用simple adapter 客製getview畫面

 2.AyncTask非同步背景呼叫json service
  使用AyncTask呼叫 才不會有NetworkOnMainThreadException

3.回傳資料:JSONArray

   轉換成 List<Map<String,Object>> 資料格式

4.硬體控制:使用CAMERA FLASH 當作手電筒

 5.需開啟權限:INTERNET,CAMERA 

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />



 

michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

直接輸入YOUTUBE網址就可以了.. http://chordify.net/
主和弦的地方準確率應該是80%以上
以後抓歌不用那麼辛苦了


未命名  


michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

1.基本安裝設定
1.Java 安裝(JAVA+JRE)

1-1 eclipse 初次使用者:  安裝adt-bundle (包含eclipse + android sdk +android platform tools)
      已是eclipse的使用者: 加裝android sdk,並於sdk中選擇安裝android platform tools(ex:4.0,2.0..)
2.執行eclipse

3.設定workspace

4.模擬器AVD Manager 新增AVD
   設定:HVGA/512MB
   Start: Scale display to resize
   Screen size(in): 5 
   Launch
   模擬器每次啟動很慢,啟動後就不要關

2.元件練習
1.使用editText,button,textview 元件
   設定fill_parent
2.setOnClickListener,輸入new 按alt+/
    會列出Event清單,選擇OnClickListener
    自動產生匿名function 

       final EditText ed1=(EditText)findViewById(R.id.editText1);;
        Button btn1=(Button)findViewById(R.id.button1);
        final TextView tv1=(TextView)findViewById(R.id.textView1);;
           //new alt+/
        btn1.setOnClickListener(new Button.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				tv1.setText("我是"+ed1.getText().toString());
			}
		});

 






3.Application Component

四大元件:Activity, Service, Broadcast receiver, Content Provider
Activity:UI/互動/費時的放到Service/避免ANR(Android is Not Responding)
            Life Cycle要記熟
activity_lifecycle  
Service:長時間執行,無UI
             ex:撥放音樂,接收網路,壓縮
             利用binding 
Activity轉換:Intent


IntentActivity

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final EditText ed =  (EditText)findViewById(R.id.editText1);
        Button btn1 = (Button)findViewById(R.id.button1);
        Button btn2 = (Button)findViewById(R.id.button2);
        
        btn1.setOnClickListener(new Button.OnClickListener() {			
			public void onClick(View v) {
				//Start the activity connect to the Result
				try{
					Intent intentResult=new Intent(Project01_IntentActivity.this,ResultAcvivity.class);
					intentResult.putExtra("username", ed.getText().toString());
					startActivity(intentResult);
					Log.e("IntentActivity","ed.getText="+ed.getText().toString());
				}catch(Exception e){
						Log.e("IntentActivity",e.toString());
				}
			
			}
		});

 



ResultActivity

protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		  setContentView(R.layout.main2);
		try{
			 TextView tv=(TextView)findViewById(R.id.textView1);
			 Intent intent=getIntent();
			 tv.setText("我是Activity2,username="+intent.getStringExtra("username"));
		}catch(Exception e){
			 Log.e("ResultAcvivity",e.toString());
		}
	}

 



1.建立2個Activity
    1.1 Package右鍵new Class
    1.2 Name:ex: ResultActivity 
    1.3 Supperclass 選擇android.app.Activity
 2.AndroidMainfest.xml
    2.1雙擊後,點選設定頁面:Application/Application Nodes/Add
    2.2選擇Activity
    2.3Attributes for Activity:輸入Name(或Browser選擇Class,ResultActivity)

    



michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

Real-World Sample Code

 

 

參考http://www.dofactory.com/Patterns/Patterns.aspx

Demo

常用

Creational Patterns

 

5

  Abstract Factory

  Creates an instance of several families of classes

 

2

  Builder

  Separates object construction from its representation

 

5

  Factory Method

  Creates an instance of several derived classes

 

3

  Prototype

  A fully initialized instance to be copied or cloned

Singleton.aspx

4

  Singleton

  A class of which only a single instance can exist

 

Demo

 

  Structural Patterns

 

4

  Adapter

  Match interfaces of different classes

 

3

  Bridge

  Separates an object’s interface from its implementation

 

4

  Composite

  A tree structure of simple and composite objects

 

3

  Decorator

  Add responsibilities to objects dynamically

Facade.aspx

5

  Facade

  A single class that represents an entire subsystem

 

1

  Flyweight

  A fine-grained instance used for efficient sharing

 

4

  Proxy

  An object representing another object

 

Demo

 

  Behavioral Patterns

 

2

  Chain of Resp.

  A way of passing a request between a chain of objects

 

4

  Command

  Encapsulate a command request as an object

 

1

  Interpreter

  A way to include language elements in a program

 

5

  Iterator

  Sequentially access the elements of a collection

 

2

  Mediator

  Defines simplified communication between classes

 

1

  Memento

  Capture and restore an object's internal state

 

5

  Observer

  A way of notifying change to a number of classes

 

3

  State

  Alter an object's behavior when its state changes

 

4

  Strategy

  Encapsulates an algorithm inside a class

 

3

  Template Method

  Defer the exact steps of an algorithm to a subclass

 

1

  Visitor

  Defines a new operation to a class without change

 

 

 

michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

dofactory.com c# 程式碼規範
http://www.dofactory.com/reference/csharp-coding-standards.aspx

其他參考:微軟官方/開發類別庫的設計方針 

http://msdn.microsoft.com/zh-tw/library/ms229042(v=vs.100).aspx

1.do
2.do not
3.avoid



do


1-1.Class,Method:Pascal
 use PascalCasing for class names and method names

sample:
 public class ClientActivity
 public void ClearStatistics()

Reason:
 與.net 規則相同,易讀


1-2 Class,Method,Property,Field 類別/方法/屬性/欄位:Pascal
 use PascalCasing for 字母以上的單字,若只有兩個字母則兩個都大寫
sample:
 HtmlHelper htmlHelper;
 FtpTransfer ftpTranfer;
 UIControl uiControl;

Reason:
 與.net 規則相同,UI較清楚


 

2-1.參數/變數:駝峰
 use camelCasing for method arguments and local variables.
sample:

public class UserLog{
  public void Add(LogEvent logEvent)    {       
  int itemCount = logEvent.Items.Count;      
   // ...   
 }
}

Reason: 與.net 規則相同,易讀


3-1  使用預先訂義好的變數,取代Int16,Single,
do use predefined type names instead of system type names like Int16, Single, UInt64, etc

// Correct
string firstName;
int lastIndex;
bool isSaved;

// Avoid
String firstName;
Int32 lastIndex;
Boolean isSaved;

Reason:
 與.net 規則相同,易讀

4.使用var 給local變數使用,除了內建的資料型別(int,string,double)
use implicit type var for local variable declarations. Exception:   (int, string,
          double, etc) use predefined names.
Sample;
var stream = File.Create(path);
var customers = new Dictionary<int?, Customer>();

 // Exceptions
int index = 100;
string timeSheet;
bool isCompleted;

Reason:移除混亂或特別的複雜型別
Why: removes clutter, particularly with complex generic types. Type is easily detected with Visual Studio tooltips.

5.使用名詞或名詞片語 來命名class
do use noun or noun phrases to name a class.
public class Employee{}p
ublic class BusinessLocation{}
public class DocumentCollection{}

Reason:
 與.net 規則相同,好記

6.介面前置詞為I,介免使用名詞或形容詞
doprefix interfaces with the letter I.  Interface names are noun (phrases) or adjectives.

public interface IShape{}
public interface IShapeCollection{}  //名詞
public interface IGroupable{}        //形容詞
Reason:
 與.net 規則相同

7.class名稱盡量跟檔案名稱相符,除了IDE自動產生對應的檔案之外(desingner)
do name source files according to their main classes. Exception: file names with partial classes
          reflect their source or purpose, e.g. designer, generated, etc.

// Located in Task.cs
public partial class Task{   
//...
}

// Located in Task.generated.cs
 public partial class Task{
 //...
}
Reason:
 與.net 的實例相同,檔案或partial class 排序會接近

8.將namespace分類清楚
do organize namespaces with a clearly defined structure

// Examples
namespace Company.Product.Module.SubModule
namespace Product.Module.Component
namespace Product.Layer.Module.Group
Reason:
 與.net 規則相同,並可維持好的原始碼基礎

9.原始碼垂直要對齊
do vertically align curly brackets.
// Correct
class Program{   
               static void Main(string[] args)   
               {   
               }
}

Reason:
 微軟有不一樣的標準,但開發者一般喜歡對齊

10.宣告所有的member 變數於class上方 ,static的變數 為最上方
do declare all member variables at the top of a class, with static variables at the very top.

// Correct
 public class Account{

 public static string BankName;
 public static decimal Reserves;
 public string Number {get; set;}
 public DateTime DateOpened {get; set;}
 public DateTime DateClosed {get; set;}
 public decimal Balance {get; set;}
     // Constructor   
 public Account()    {       
 // ...   
 }
}

Reason: 一般可以接受的實例,避免要尋找變數

11.使用單字for enums, 例外:bit
do use singular names for enums. Exception: bit field enums.
// Correct
 public enum Color{   
 Red,   
 Green,   
 Blue,   
 Yellow,   
 Magenta,   
 Cyan}

// Exception
[Flags]
public enum Dockings{   
 None = 0,   
 Top = 1,    
 Right = 2,    
 Bottom = 4,   
 Left = 8
}

Reason:
 與.net 規則相同,易讀,(複數的flag可以用or運算)

 

 

do not

1.不要使用:匈牙利命名
do not use Hungarian notation or any other type identification in identifiers

Sample:
// Correct
int counter;string name;
// Avoid
int iCounter;string strName

Reason: 與.net 規則相同,IDE裡要判別型別很容易,不需要加上型別


2.不要使用全大寫 (常數或readonly)
do notuse Screaming Caps for constants or readonly variables
// Correct
public static const string ShippingType = "DropShip";
// Avoid
public static const string SHIPPINGTYPE = "DropShip";

Reason:與.net 規則相同,大寫太容易引人注意

 

3.不要使用底線,例外(private 變數可以用底線開頭)
do notuse Underscores in identifiers. Exception: you can prefix private static variables
                    with an underscore.

// Correct
 public DateTime clientAppointment;
 public TimeSpan timeLeft;
// Avoid
 public DateTime client_Appointment;
 public TimeSpan time_Left;
// Exception
private DateTime _registrationDate;


Reason:與.net 規則相同,容易閱讀,避免印刷模糊,或底線格式下看不到


4.enum不要指定型態(例外,bit)
do not
explicitly specify a type of an enum or values of enums (except bit fields)

// Don't
public enum Direction : long{    North = 1,    East = 2,    South = 3,    West = 4}

// Correct
public enum Direction{    North,    East,    South,    West}


Reason:會混淆到底是依賴name or value

 

5.enum的名字中 不要加Enum字眼
do not suffix enum names with Enum

// Don't
public enum CoinEnum{    Penny,    Nickel,    Dime,    Quarter,    Dollar}
// Correct
public enum Coin{    Penny,    Nickel,    Dime,    Quarter,    Dollar}

reason:與.net 規則相同,不加入資料型別在宣告名稱內


avoid

1.避免使用縮寫(除非是常用的縮寫)

avoidusing Abbreviations. Exceptions: abbreviations commonly used as names,
                 such as Id, Xml, Ftp, Uri
// Correct
UserGroup userGroup;
Assignment employeeAssignment;
// Avoid
UserGroup usrGrp;
Assignment empAssignment;
// Exceptions
CustomerId customerId;
XmlDocument xmlDocument;
FtpHelper ftpHelper;
UriPart uriPart;

Reason: 與.net 規則相同,防止不一致的縮寫


 

michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()

自上次渣打後,只練了三次 最多5km 加上最近一直感冒,一起跑步就頭痛

今天只拖著老命去走完..本次超半馬是繞著明德水庫跑兩圈
第一圈跑跑走走,第二圈連下坡都快走不下去了,膝蓋已經不大行了

本次參加人員:威益,Warren,Michael

值得一提的是拍完以下合照後,我的蝴蝶機應聲倒地,面板破裂,但還可以操作











這成績應該是 超馬的成績,所以把半遮起來...



michaelfang 發表在 痞客邦 PIXNET 留言(0) 人氣()