Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
1569 lines (1138 sloc) 81.1 KB
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Mario's Blog</title>
<meta name="author" content="Mario">
<meta name="description" content="Published on: Nov 19th, 2014 Tag: wish 每天扫一次地,每周拖一次地。家就是净土,把家打扫干净了,就是扫除心灵中的一些污垢 日期 打扫 2014年11月19日 Yes | 修持八正道
让心安住在当下
放慢做事的速度
平常多念“嗡嘛呢贝咪哞”净化自心, &hellip;">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="/atom.xml" rel="alternate" title="Mario's Blog" type="application/atom+xml">
<link rel="canonical" href="">
<link href="/favicon.ico" rel="shortcut icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Slackey' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Fjalla+One' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Amethysta' rel='stylesheet' type='text/css'>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script type="text/javascript" src="/javascripts/jquery-tapir.js"></script>
<!-- remove or comment it to disable ajaxification -->
<!-- <script src="/javascripts/ajaxify.js"></script> -->
</head>
<body>
<div id="wrapper">
<header id="header" class="inner"><!-- for more effects see _animate.scss -->
<h1 class="animated bounceInDown">
<div id="headerbg">
Mario
</div>
</h1>
<br>
<h3 class="animated bounceInDown">
<div id="headerbg">
吾尝终日而思矣,不如须臾之所学也!
</div>
</h3>
<ul id="social-links" style="text-align:center">
<!-- GitHub -->
<li>
<a href="https://github.com/sweetdark" class="github" title="Github"></a>
</li>
</ul>
<!-- use full url including 'index.html' for navigation bar if you are using ajax -->
<ul id="nav">
<li id="ajax"><a href="/index.html">Home</a></li>
<li id="ajax"><a href="/blog/archives/index.html">Archives</a></li>
<li id="ajax"><a href="/tag/index.html">Tags</a></li>
<li id="ajax"><a href="/about/index.html">About</a></li>
<li>
<div id="dark">
<form method="get" action="/search.html" id="search">
<input name="query" type="text" placeholder="Search..." x-webkit-speech />
</form>
</div>
</li>
</ul>
</header>
<div id="toload">
<!-- begin toload -->
<div id="content" class="inner">
<div class="blog-index">
<article class="post">
<h2 class="title">
<a href="/blog/2014/11/19/wish-and-plan/">
计划和发愿</a>
</h2>
<div class="entry-content">
<div class="meta">
<div class="date">Published on:
<time datetime="2014-11-19T22:03:17+08:00" pubdate data-updated="true">Nov 19<sup>th</sup>, 2014</time></div>
<div class="tags">
Tag:
<a href='/blog/tags/wish/'>wish</a>
</div>
</div>
<ul>
<li>每天扫一次地,每周拖一次地。家就是净土,把家打扫干净了,就是扫除心灵中的一些污垢</li>
</ul>
<table>
<thead>
<tr>
<th></th>
<th> 日期 </th>
<th> 打扫 </th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td> 2014年11月19日 </td>
<td> Yes |</td>
</tr>
</tbody>
</table>
<ul>
<li>修持八正道</li>
<li>让心安住在当下</li>
<li>放慢做事的速度</li>
<li>平常多念“嗡嘛呢贝咪哞”净化自心,三个月内要念10万遍</li>
</ul>
</div>
<div class="meta">
<span class="comments"><a href="/blog/2014/11/19/wish-and-plan//index.html#disqus_thread">Comments</a></span>
</div>
</article>
<article class="post">
<h2 class="title">
<a href="/blog/2014/10/28/why-study-buddha/">
为什么学佛</a>
</h2>
<div class="entry-content">
<div class="meta">
<div class="date">Published on:
<time datetime="2014-10-28T19:11:16+08:00" pubdate data-updated="true">Oct 28<sup>th</sup>, 2014</time></div>
<div class="tags">
Tag:
<a href='/blog/tags/buddha/'>buddha</a>
</div>
</div>
<h2>为什么学习佛法</h2>
<ul>
<li>断除烦恼,增长智慧。</li>
<li>自利利他。</li>
<li>身心自由,得大自在。</li>
<li>修福修慧,解决人生的问题,心灵的问题,社会的问题。</li>
</ul>
<h2>学习佛法之后要知道</h2>
<ul>
<li>要好好的孝顺父母。</li>
<li>知道了因果。所以要修一切善法,断一切恶念。</li>
<li>要忍辱,善待周围的人。</li>
<li>尊重他人,他人都是未来佛。</li>
<li>利益他人就是利益自己。</li>
<li>要除掉自己的贪嗔痴。</li>
</ul>
<h2>古今圣贤和科学人士对教的评价</h2>
<ol>
<li>康有为
“佛学之博大精深,虽有圣哲无所措手”。</li>
<li>梁启超
“佛学广矣,大矣,深矣,微矣,切于人事,证于实用,实天地间最高尚圆满,深地著名之学说也。佛教之信仰,乃智信而非迷信”。</li>
<li>谭嗣同
“佛教大矣,孔次大,耶为小”。</li>
<li>孙中山
“佛学乃哲学之母,研究佛学,可补科学之偏”。</li>
<li>章太炎
“佛教的理论,使上智人不能不信”。</li>
<li>鲁迅
“释迦牟尼真是大哲,我平常对人生有许多难以解答的问题,他居然早已明白的启示了”。</li>
<li>早期马克思哲学宣传者 李石岑
我认为佛学的提倡,不特于对科学毫无抵触,而且能使科学的方法上加一层深密,科学的分类上加一层正确,科学的效果上加一层保证。</li>
<li>陈独秀
“佛法之广大精深,余所素信不疑者也”</li>
<li>沈家祯博士
我本人是科学家,但对佛法同样感兴趣。我认为佛法与科学是一而二,二而一的。佛教的《般若经》、《入胎经》、《楞严经》等经论对大到宇宙自然,小到人体本身的生老病死都进行了客观辩证的阐释,且越来越得到了近代和现代科学的证明,而佛教高僧的虹化现象,也只有用爱因斯坦的相对论来加以解释。</li>
<li><p>中国现代科学家 尤智表 博士
佛教不但不是迷信,而且是破除迷信最彻底的学理,科学造诣深者,愈能解释佛经中素心的真义。</p></li>
<li><p>马克思
辩证法在佛教中已达到很精细的程度。</p></li>
<li>恩格斯
佛教徒处在理性思维的高级阶段。人类到释迦牟尼佛时代,辩证思维才成熟。辩证法最初来源于佛教。</li>
<li>尼采
佛教是历史上唯一真正注重和依据实证的宗教。</li>
<li>英国著名哲学家 伯特兰?罗素
“我并不觉得基督在智慧或德行上比其他一些有名望的人要高,我想,我会把佛陀的位置摆在基督的前面。多种宗教中,我所赞成的是佛教。历史上所有宗教中,我对佛教最具好感,尤其是它初级的形式,含有最少压迫性的因素”。“我觉得不论智慧或人格,佛陀都远远超过其他宗教创始人”。</li>
<li>爱因斯坦
“单靠知识和技巧,不能使人类走上幸福和高尚的生活。人类有充分的理由,把那些崇高的道德标准和道德价值的传播者,置于客观真理的发现之上。对我来说,人类应该感谢释迦牟尼佛和耶稣那样的人物,远比应该感谢所有创造性的好奇的头脑的成就要多得多。”
“在我们这个唯物论的年代,只有严肃的科学工作者,才是深信宗教的人”。
“如果有一个能够应付现代科学需求,又能与科学相依共存的宗教,那必定是佛教”。
“佛学是一切真正科学的原动力”。爱因斯坦所写自传的谈论中谈到,他不是一名宗教徒,但如果他是的话,他愿成为一名佛教徒。爱因斯坦还说:“未来的宗教是一种宇宙宗教。它将是一种超越人格化神,远离一切教条和神学的宗教。这种宗教,包容自然和精神两个方面,作为一个有意义的统一体,必定是建立在由对事物的——无论是精神,还是自然的——实践与体验而产生的宗教观念之上的。佛教符合这种特征”。(出自1954年普林斯顿大学出版社出版的《Albert Einstein: The Human Side》一书)。
爱因斯坦还说:“没有科学的宗教是瘸子,没有宗教的科学是瞎子”。
“空间、时间和物质,是人类认识的错觉”。
爱因斯坦表示他很欣赏佛教,他曾说道:“佛教具有未来世界宗教可能期待的特点:它超越了一个人格化的神,避免了教条和神学,它包涵物质和精神两方面,同时它作为有机的整体植根于对自然和精神世界所有事物的经验,以此为宗教信仰的灵感。”</li>
<li>埃德温?阿若德
“我常说,而且将一直这么说,在佛教与科学之间存在着一股智慧的粘合力”。
“我说过,我还要说,我还要一遍又一遍的说,佛教与现代科学之间存在着一条紧密的智力纽带。”</li>
<li>克里斯特姆斯?汉普里斯:
“佛教是一种思想体系,一种宗教,一种精神科学,一种生活方式。它合理、现实,包容一切,2500年来,它满足了世界上近三分之一的精神需要,它深深地被西方世界所吸引,它在坚持“依靠自力”的同时,采取对其他观点的宽容态度,它包容了科学、宗教、哲学、心理学、伦理和艺术,它指出:人是他自己现实生活的创造者和他自己命运的唯一设计者”。</li>
<li>艾基尔顿?巴普铁斯特《超然的佛教科学》
“在面对原子方面,科学不能给人以确切的保证,而佛教完全可以应付原子的挑战,这是因为佛教超凡的智慧始于科学所不能应对和解决的地方。这对从事佛学研究的人来说是显而易见的。因为,通过佛教的禅定,原子的成分构成物质的过程,便可如实看到或觉察到。而物质的生与灭所引起的忧伤与痛苦均源于所谓的“灵魂”或“梵我”等法执之妄见,这便是佛经里所阐述的”。</li>
<li>世界著名学者巴格尔
在世界宗教中,只有佛教是切实地以系统理性的分析来考察生活中的问题,并寻找解决问题的方法。</li>
<li>世界几何学之父 威勒 博士曾说
假使没有佛教因果律,宇宙就只有混乱。
23.美国心理学家文巴克 博士
通过特殊的催眠方法约有百分之七十的人,可鲜明地回忆前世(这就是佛教称的前世)记忆,甚至有的可追忆到自己前九世的境况。</li>
<li>著名物理学家威斯柯夫 认为:
“在科学上,几乎每件事都是超过你直接经验的。世间人往往仅以自已的见闻和经验来评判事物,但他不知道,我们的感觉和经验经常在欺骗自已”(此与佛教类同)。
(佛教是伟大而科学的教育,早在二千五百年前,佛教就以其非凡超卓的思想唤醒人类,使人类从一切缠缚和迷执中解脱出来。佛陀曾告诫弟子们应该去培养和发展自身的潜能,不要做他人的奴隶,要充分利用自己的意志和智慧找到那永恒的真理。这种永恒的真理,正是佛陀向人类所宣说的,是靠他自己的实践亲证达到的。佛的言教不带有任何宗教色彩,任何人均可对它进行实践。)</li>
<li><p>出家人是最高尚最伟大的,顺治皇帝曾作&#8221;黄金白玉非为贵,唯有袈裟披肩难&#8221;之赞誉。 
      &mdash;&mdash;-著名书画曲剧家 李叔同</p></li>
<li><p>王永庆的外孙女哈佛才女:杨元宁20岁的慈悲之心<a href="http://www.folou.com/thread-278114-1-1.html">http://www.folou.com/thread-278114-1-1.html</a></p></li>
</ol>
</div>
<div class="meta">
<span class="comments"><a href="/blog/2014/10/28/why-study-buddha//index.html#disqus_thread">Comments</a></span>
</div>
</article>
<article class="post">
<h2 class="title">
<a href="/blog/2014/10/09/java-programming-guide/">
Java 风格指南</a>
</h2>
<div class="entry-content">
<div class="meta">
<div class="date">Published on:
<time datetime="2014-10-09T21:07:38+08:00" pubdate data-updated="true">Oct 9<sup>th</sup>, 2014</time></div>
<div class="tags">
Tag:
<a href='/blog/tags/programming/'>programming</a>
</div>
</div>
<p>[TOC]</p>
<h1>Java Programming Guide</h1>
<blockquote><p>软件首要的技术革命是管理复杂度</p><footer><strong>Steve McConnel</strong> <cite>Code Complete</cite></footer></blockquote>
<blockquote><p>代码越多,问题也就越多</p><footer><strong>Biggie Smalls</strong></footer></blockquote>
<blockquote><p>代码被阅读的次数远远多于写的次数
任何一个傻瓜都会写出能够让机器理解的代码,只有好的程序员才能写出人类可以理解的代码</p></blockquote>
<p>编码规范的目的是在团队中达成一种共识,从而编写出易于阅读和维护的代码。值得庆幸的是Java中有现成的规范和代码风格工具,以及风格检查工具。</p>
<!-- 使用github MarkdDown扩展的语法 -->
<h2>通用命名规范</h2>
<ul>
<li>包命名规范
<blockquote><p>包名统一用小写 mypackage, cn.ritu.cn</p></blockquote></li>
<li>类型名用大小写混合的方式,第一个字母大写. UserInfo</li>
<li>变量名也用大小写混合的方式,第一个字母小写 lineCount</li>
<li>常量全部大写,多个单词之间用_下划线隔开
<blockquote><p>常量是指那些它的内容一直不会改变的量,而不只是声明为final就可以了,如</p></blockquote></li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="kd">static</span> <span class="kd">final</span> <span class="kt">int</span> <span class="n">MIN_TIMES</span> <span class="o">=</span> <span class="mi">30</span><span class="o">;</span>
</span><span class='line'> <span class="kd">static</span> <span class="kd">final</span> <span class="n">ImmutableList</span><span class="o">&lt;</span> <span class="n">String</span> <span class="o">&gt;</span> <span class="n">NAMES</span> <span class="o">=</span> <span class="n">ImmutableList</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">&quot;Ed&quot;</span><span class="o">);</span>
</span><span class='line'> <span class="c1">//下面的不是常量</span>
</span><span class='line'> <span class="kd">final</span> <span class="n">String</span> <span class="n">nonStatic</span> <span class="o">=</span> <span class="s">&quot;non-static&quot;</span><span class="o">;</span>
</span><span class='line'> <span class="kd">static</span> <span class="n">String</span> <span class="n">nonFinal</span> <span class="o">=</span> <span class="s">&quot;non-final&quot;</span><span class="o">;</span>
</span><span class='line'> <span class="kd">static</span> <span class="kd">final</span> <span class="n">Set</span><span class="o">&lt;</span> <span class="n">String</span> <span class="o">&gt;</span> <span class="n">mutableCollection</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashSet</span><span class="o">&lt;</span> <span class="n">String</span> <span class="o">&gt;();</span>
</span><span class='line'> <span class="kd">static</span> <span class="kd">final</span> <span class="n">ImmutableSet</span><span class="o">&lt;</span> <span class="n">SomeMutableType</span> <span class="o">&gt;</span> <span class="n">mutableElements</span> <span class="o">=</span> <span class="n">ImmutableSet</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="n">mutable</span><span class="o">);</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>方法名用动名词结合的方式,第一个字母小写,大小写混合的方式。不要出现模糊不清的命名情况,如search();</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="n">getName</span><span class="o">();</span>
</span><span class='line'><span class="n">vertex</span><span class="o">.</span><span class="na">findNearestVertex</span><span class="o">();</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li>在名字中如果有缩写也要使用大小写混合的方式</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="n">exportHtmlSource</span><span class="o">();</span> <span class="c1">//而不是exportHTMLSource();</span>
</span><span class='line'> <span class="n">openDvdPlayer</span><span class="o">();</span> <span class="c1">//而不是openDvdPlayer();</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>类中的私有变量要单独用一种方式来表示,在名字后面用_下划线,或者用m_开头,有待讨论。 如:</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="kd">class</span> <span class="nc">Person</span>
</span><span class='line'> <span class="o">{</span>
</span><span class='line'> <span class="kd">private</span> <span class="n">String</span> <span class="n">name_</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>通用的常量的名字应该和它的类型保持一致</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="kt">void</span> <span class="nf">setTopic</span><span class="o">(</span><span class="n">Topic</span> <span class="n">topic</span><span class="o">)</span> <span class="c1">// NOT: void setTopic(Topic value)</span>
</span><span class='line'> <span class="c1">// NOT: void setTopic(Topic aTopic)</span>
</span><span class='line'> <span class="c1">// NOT: void setTopic(Topic t)</span>
</span><span class='line'>
</span><span class='line'> <span class="kt">void</span> <span class="nf">connect</span><span class="o">(</span><span class="n">Database</span> <span class="n">database</span><span class="o">)</span> <span class="c1">// NOT: void connect(Database db)</span>
</span><span class='line'> <span class="c1">// NOT: void connect(Database oracleDB)</span>
</span><span class='line'><span class="c1">// 更具体一点,可以用角色加类型组合的方式来表达</span>
</span><span class='line'> <span class="n">Point</span> <span class="n">startingPoint</span><span class="o">,</span> <span class="n">centerPoint</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>作用域大的变量必须使用具体的长名字来表示,很小范围的可以用缩写如循环中的循环变量i,j,k 如果是多层嵌套则要考虑使用更具体的名字来命名循环变量,如bookIndex</li>
<li>尽量给临时变量起一个更好的名字,不要用temp。</li>
<li>不要把对象的名字或类的名字包含在方法名中</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="n">line</span><span class="o">.</span><span class="na">getLength</span><span class="o">();</span> <span class="c1">//NOT:line.getLineLength();</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<h3>特定的命名规范</h3>
<ul>
<li>get/set 用于访问成员的属性</li>
<li>is前缀的用于布尔变量和返回布尔的方法,有时用has和can前缀更加合适</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="n">isSet</span><span class="o">,</span> <span class="n">isVisible</span><span class="o">,</span> <span class="n">isFinished</span><span class="o">,</span> <span class="n">isFound</span><span class="o">,</span> <span class="n">isOpen</span>
</span><span class='line'> <span class="kt">void</span> <span class="nf">setFound</span><span class="o">(</span><span class="kt">boolean</span> <span class="n">isFound</span><span class="o">);</span>
</span><span class='line'> <span class="kt">boolean</span> <span class="nf">hasLicense</span><span class="o">();</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li><em>compute</em>可以被用于那些表示计算的方法</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="n">valueSet</span><span class="o">.</span><span class="na">computeAverage</span><span class="o">();</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li><em>find</em>用于查找的方法</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="n">vertex</span><span class="o">.</span><span class="na">findNearestVertex</span><span class="o">();</span>
</span><span class='line'><span class="n">matrix</span><span class="o">.</span><span class="na">findSmallestElement</span><span class="o">();</span>
</span><span class='line'><span class="n">node</span><span class="o">.</span><span class="na">findShortestPath</span><span class="o">(</span><span class="n">Node</span> <span class="n">destinationNode</span><span class="o">);</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li><em>initialize</em> 术语用在对象初始化的时候,不要使用<em>init</em>
<blockquote><p>printer.initializeFontSet();</p></blockquote></li>
<li>GUI控件的命名应该包含控件的类型
<blockquote><p>widthScale, nameTexField, leftScrollbar</p></blockquote></li>
<li>复数用于表示集合对象</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="n">Collection</span><span class="o">&lt;</span> <span class="n">Point</span> <span class="o">&gt;</span> <span class="n">points</span><span class="o">;</span>
</span><span class='line'><span class="kt">int</span><span class="o">[]</span> <span class="n">values</span><span class="o">;</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li><em>n</em>前缀可以用于表示若干个对象,这种情况下num不应该被使用
<blockquote><p>nPoints, nLines</p></blockquote></li>
<li><em>No</em>或者<em>total</em>后缀表示对象的总数,而且仅仅使用其中一种方式来表示,不要同时使用</li>
<li><p><em>Min</em>, <em>Total</em>, <em>Sum</em>, <em>Max</em>,<em>Average</em> 这些表示数量,总量,平均值,最大值,总额的限定词统一作为后缀
不要出现前后都有的情况,revenueTotal和totalRevenue这会产生迷惑</p>
<blockquote><p>revenueTotal(总收入),expanseTotal(总支出)</p></blockquote></li>
<li><p>使用对仗词语来命名,如果出现了其中一个,通常情况下也要有另外一个。常见的对仗词有</p>
<blockquote><p>get/set, add/remove, create/destroy, start/stop, insert/delete,
increment/decrement, old/new, begin/end, first/last, up/down, min/max,
next/previous, old/new, open/close, show/hide, suspend/resume, etc.</p></blockquote></li>
<li>不要使用缩写,除了那些领域中的专业词汇。如:html, cpu
<blockquote><p>下列的缩写是不可取的:
cmd 代替 command
comp 代替 compute,compare
cp 代替 copy
init 代替 initialize</p></blockquote></li>
<li>不要使用否定的布尔变量
<blockquote><p>bool isError; // NOT: isNoError
bool isFound; // NOT: isNotFound</p></blockquote></li>
<li>常量要加上类型的前缀</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="kd">final</span> <span class="kt">int</span> <span class="n">COLOR</span><span class="err">\</span><span class="n">_RED</span> <span class="o">=</span> <span class="mi">1</span><span class="o">;</span>
</span><span class='line'><span class="kd">final</span> <span class="kt">int</span> <span class="n">COLOR</span><span class="err">\</span><span class="n">_GREEN</span> <span class="o">=</span> <span class="mi">2</span><span class="o">;</span>
</span><span class='line'><span class="kd">final</span> <span class="kt">int</span> <span class="n">COLOR</span><span class="err">\</span><span class="n">_BLUE</span> <span class="o">=</span> <span class="mi">3</span><span class="o">;</span>
</span><span class='line'><span class="c1">//或者使用</span>
</span><span class='line'><span class="kd">interface</span> <span class="nc">Color</span>
</span><span class='line'><span class="o">{</span>
</span><span class='line'> <span class="kd">final</span> <span class="kt">int</span> <span class="n">RED</span> <span class="o">=</span> <span class="mi">1</span><span class="o">;</span>
</span><span class='line'> <span class="kd">final</span> <span class="kt">int</span> <span class="n">GREEN</span> <span class="o">=</span> <span class="mi">2</span><span class="o">;</span>
</span><span class='line'> <span class="kd">final</span> <span class="kt">int</span> <span class="n">BLUE</span> <span class="o">=</span> <span class="mi">3</span><span class="o">;</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li>异常类后缀应该加上Exception</li>
<li>接口的默认实现应该加上前缀Default</li>
<li>Singleton 单例类通过getInstance方法来获取单例</li>
<li>工厂类创建对象使用new[类名]的方法来创建</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="kd">class</span> <span class="nc">PointFactory</span>
</span><span class='line'><span class="o">{</span>
</span><span class='line'> <span class="kd">public</span> <span class="n">Point</span> <span class="nf">newPoint</span><span class="o">()</span>
</span><span class='line'> <span class="o">{...}</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li>函数在名称中应该包含它要返回的类型信息,过程的名称则应该具体的描述它做了什么</li>
</ul>
<h2>文件规范</h2>
<ul>
<li>Java文件名首字母大写如Point.java</li>
<li>每个类单独为一个文件,并且和文件名一样。私有的类可以声明为内部的嵌套类</li>
<li>每一行的长度应该控制在80列以内</li>
<li>统一使用2个空格作用缩进,TAB要转换为缩进</li>
<li>未完成的行应该明显的表示出来。</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="n">totalSum</span> <span class="o">=</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span> <span class="o">+</span> <span class="n">c</span> <span class="o">+</span>
</span><span class='line'> <span class="n">d</span> <span class="o">+</span> <span class="n">e</span><span class="o">;</span>
</span><span class='line'><span class="n">method</span><span class="o">(</span><span class="n">param1</span><span class="o">,</span> <span class="n">param2</span><span class="o">,</span>
</span><span class='line'> <span class="n">param3</span><span class="o">);</span>
</span><span class='line'><span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">tableNo</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">tableNo</span> <span class="o">&lt;</span> <span class="n">nTables</span><span class="o">;</span>
</span><span class='line'> <span class="n">tableNo</span> <span class="o">+=</span> <span class="n">tableStep</span><span class="o">)</span>
</span><span class='line'><span class="cm">/*</span>
</span><span class='line'><span class="cm">* 在逗号,分号和操作符等断开,然后下一行的开始与上一行表达式的开始平行</span>
</span><span class='line'><span class="cm">*/</span>
</span></code></pre></td></tr></table></div></figure>
<h2>语句</h2>
<h3>package和import语句</h3>
<ul>
<li>package语句必须在文件的第一句,import语句跟在package语句的后面。 按照功能进行分组,每个组之间用空行分开。按照字典顺序进行排序。</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="kn">import</span> <span class="nn">java.io.IOException</span><span class="o">;</span>
</span><span class='line'><span class="kn">import</span> <span class="nn">java.net.URL</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'><span class="kn">import</span> <span class="nn">java.rmi.RmiServer</span><span class="o">;</span>
</span><span class='line'><span class="kn">import</span> <span class="nn">java.rmi.server.Server</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'><span class="kn">import</span> <span class="nn">javax.swing.JPanel</span><span class="o">;</span>
</span><span class='line'><span class="kn">import</span> <span class="nn">javax.swing.event.ActionEvent</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'><span class="kn">import</span> <span class="nn">org.linux.apache.server.SoapServer</span><span class="o">;</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>引入的类要列出来,不要使用整个包引入的方式java.util.* 来引入整个包;
<h3>类和接口</h3></li>
<li>类和接口的声明顺序
<blockquote><ol>
<li>类和接口的文档说明</li>
<li>类和接口的语句 class 或者 interface</li>
<li>类和接口的变量(包括静态变量)按照public, protected, package,private的顺序列出</li>
<li>构造函数</li>
<li>方法
<h3>方法</h3></li>
</ol>
</blockquote></li>
<li>方法修饰符的顺序
<blockquote><p>访问权限( public, protected, private ) static abstract synchronized final native的顺序</p></blockquote></li>
<li>类型转换
<h3>类型</h3></li>
<li>类型转换必须强制声明,强制转换的前后要留空格 int length = (int) getLength();</li>
<li>数组的声明[]应该紧跟着类型名 String[] names; int[] values;
<h3>变量</h3></li>
<li>变量应该的定义的时候初始化,定义在最小的作用域范围内,在要使用的地方进行定义</li>
<li>一个变量名不应该有双重含义, 如变量 x的第一位来表示某个标志位,后面的倍数来表示坐标</li>
<li>类变量不应该被声明为pulibc,除非这个类是作为结构体使用</li>
<li>变量的生命周期应该保持最短,资源用完应该及时释放
<h3>循环</h3></li>
<li>只有循环控制语句应该被放在for()结构中</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="n">sum</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span>
</span><span class='line'><span class="k">for</span> <span class="o">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="mi">100</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span>
</span><span class='line'> <span class="n">sum</span> <span class="o">+=</span> <span class="n">value</span><span class="o">[</span><span class="n">i</span><span class="o">];</span>
</span><span class='line'> <span class="n">sum</span> <span class="o">+=</span> <span class="n">value</span><span class="o">[</span><span class="n">i</span><span class="o">];</span>
</span><span class='line'><span class="c1">// NOT: for (i = 0, sum = 0; i &lt; 100; i++)</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li>循环变量应该紧挨着循环结构</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="n">isDone</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span> <span class="c1">// NOT: bool isDone = false;</span>
</span><span class='line'><span class="k">while</span> <span class="o">(!</span><span class="n">isDone</span><span class="o">)</span> <span class="o">{</span> <span class="c1">// :</span>
</span><span class='line'> <span class="o">:</span> <span class="c1">// while (!isDone) {</span>
</span><span class='line'><span class="o">}</span> <span class="c1">// :</span>
</span><span class='line'> <span class="c1">// }</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li>在循环中避免使用do-while语句</li>
<li>在循环中尽量避免使用continue和break语句</li>
</ul>
<h3>条件</h3>
<ul>
<li>避免复杂的条件判断语句,可以引用临时的布尔变量来降低复杂度</li>
<li>正常情况应该被放在if语句中,异常情况放在else语句中</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="k">if</span> <span class="o">(</span><span class="n">isOK</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">doSomething</span><span class="o">();</span>
</span><span class='line'><span class="o">}</span>
</span><span class='line'><span class="k">else</span> <span class="o">{</span>
</span><span class='line'> <span class="n">exception</span><span class="o">();</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li>条件语句应该写在单独一行,后面不要接其它的语句了</li>
<li>不要在判断中去执行语句</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="n">InputStream</span> <span class="n">stream</span> <span class="o">=</span> <span class="n">File</span><span class="o">.</span><span class="na">open</span><span class="o">(</span><span class="n">fileName</span><span class="o">,</span> <span class="s">&quot;w&quot;</span><span class="o">);</span>
</span><span class='line'><span class="k">if</span> <span class="o">(</span><span class="n">stream</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="o">:</span>
</span><span class='line'><span class="o">}</span>
</span><span class='line'>
</span><span class='line'><span class="c1">// NOT:</span>
</span><span class='line'><span class="k">if</span> <span class="o">(</span><span class="n">File</span><span class="o">.</span><span class="na">open</span><span class="o">(</span><span class="n">fileName</span><span class="o">,</span> <span class="s">&quot;w&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">))</span> <span class="o">{</span>
</span><span class='line'> <span class="o">:</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<ul>
<li>不要使用魔数,使用具名常量代替</li>
<li>浮点数的书写至少要有一个小数位</li>
<li>静态方法要使用类名来调用,不要使用对象。</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="n">Thread</span><span class="o">.</span><span class="na">sleep</span><span class="o">(</span><span class="mi">1000</span><span class="o">);</span> <span class="c1">//NOT: thread.sleep(1000); getThread().sleep(1000);</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<h2>布局和注释</h2>
<h3>布局</h3>
<ul>
<li>缩进为两个空格,TAB符要设置转换为空格</li>
<li>块布局可以是下面的两种</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="k">while</span> <span class="o">(!</span><span class="n">done</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">doSomething</span><span class="o">();</span>
</span><span class='line'> <span class="n">done</span> <span class="o">=</span> <span class="n">moreToDo</span><span class="o">();</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">while</span> <span class="o">(!</span><span class="n">done</span><span class="o">)</span>
</span><span class='line'> <span class="o">{</span>
</span><span class='line'> <span class="n">doSomething</span><span class="o">();</span>
</span><span class='line'> <span class="n">done</span> <span class="o">=</span> <span class="n">moreToDo</span><span class="o">();</span>
</span><span class='line'> <span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>类的布局如下</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="kd">class</span> <span class="nc">Rectangle</span> <span class="kd">extends</span> <span class="n">Shape</span>
</span><span class='line'> <span class="kd">implements</span> <span class="n">Cloneable</span><span class="o">,</span> <span class="n">Serializable</span>
</span><span class='line'> <span class="o">{</span>
</span><span class='line'> <span class="o">...</span>
</span><span class='line'> <span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>方法的布局如下</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">someMethod</span><span class="o">()</span>
</span><span class='line'> <span class="kd">throws</span> <span class="n">SomeException</span>
</span><span class='line'> <span class="o">{</span>
</span><span class='line'> <span class="o">...</span>
</span><span class='line'> <span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>条件语句的布局如下,判断条件要另起一行不要跟}在一行</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="k">if</span> <span class="o">(</span><span class="n">condition</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">if</span> <span class="o">(</span><span class="n">condition</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="k">else</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">if</span> <span class="o">(</span><span class="n">condition</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="k">else</span> <span class="nf">if</span> <span class="o">(</span><span class="n">condition</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="k">else</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>for语句和while语句的布局如下</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="k">for</span> <span class="o">(</span><span class="n">initialization</span><span class="o">;</span> <span class="n">condition</span><span class="o">;</span> <span class="n">update</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="err">空循环如下:</span>
</span><span class='line'> <span class="k">for</span> <span class="o">(</span><span class="n">initialization</span><span class="o">;</span> <span class="n">condition</span><span class="o">;</span> <span class="n">update</span><span class="o">)</span>
</span><span class='line'> <span class="o">;</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>switch语句的布局如下,switch语句一定要有default:即使是空的</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="k">switch</span> <span class="o">(</span><span class="n">condition</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="k">case</span> <span class="n">ABC</span> <span class="o">:</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="c1">// Fallthrough</span>
</span><span class='line'>
</span><span class='line'> <span class="k">case</span> <span class="n">DEF</span> <span class="o">:</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="k">break</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">case</span> <span class="n">XYZ</span> <span class="o">:</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="k">break</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'> <span class="k">default</span> <span class="o">:</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="k">break</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>try-catch语句布局如下</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="k">try</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">exception</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'>
</span><span class='line'> <span class="k">try</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">exception</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span><span class='line'> <span class="k">finally</span> <span class="o">{</span>
</span><span class='line'> <span class="n">statements</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<h3>空格</h3>
<ul>
<li>操作符两边要有空格</li>
<li>Java保留字后面要跟空格 如 while () , if ()</li>
<li>逗号后面要有空格</li>
<li>冒号两边都要有空格</li>
<li>在for语句中的分号后面要有空格</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="n">a</span> <span class="o">=</span> <span class="o">(</span><span class="n">b</span> <span class="o">+</span> <span class="n">c</span><span class="o">)</span> <span class="o">*</span> <span class="n">d</span><span class="o">;</span> <span class="c1">// NOT: a=(b+c)*d</span>
</span><span class='line'>
</span><span class='line'> <span class="k">while</span> <span class="o">(</span><span class="kc">true</span><span class="o">)</span> <span class="o">{</span> <span class="c1">// NOT: while(true){</span>
</span><span class='line'> <span class="o">...</span>
</span><span class='line'>
</span><span class='line'> <span class="n">doSomething</span><span class="o">(</span><span class="n">a</span><span class="o">,</span> <span class="n">b</span><span class="o">,</span> <span class="n">c</span><span class="o">,</span> <span class="n">d</span><span class="o">);</span> <span class="c1">// NOT: doSomething(a,b,c,d);</span>
</span><span class='line'>
</span><span class='line'> <span class="k">case</span> <span class="mi">100</span> <span class="o">:</span> <span class="c1">// NOT: case 100:</span>
</span><span class='line'>
</span><span class='line'> <span class="k">for</span> <span class="o">(</span><span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="mi">10</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span> <span class="c1">// NOT: for(i=0;i&lt;10;i++){</span>
</span><span class='line'> <span class="o">...</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>逻辑单元之间要隔一行空行</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="c1">// Create a new identity matrix</span>
</span><span class='line'> <span class="n">Matrix4x4</span> <span class="n">matrix</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Matrix4x4</span><span class="o">();</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// Precompute angles for efficiency</span>
</span><span class='line'> <span class="kt">double</span> <span class="n">cosAngle</span> <span class="o">=</span> <span class="n">Math</span><span class="o">.</span><span class="na">cos</span><span class="o">(</span><span class="n">angle</span><span class="o">);</span>
</span><span class='line'> <span class="kt">double</span> <span class="n">sinAngle</span> <span class="o">=</span> <span class="n">Math</span><span class="o">.</span><span class="na">sin</span><span class="o">(</span><span class="n">angle</span><span class="o">);</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// Specify matrix as a rotation transformation</span>
</span><span class='line'> <span class="n">matrix</span><span class="o">.</span><span class="na">setElement</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">,</span> <span class="n">cosAngle</span><span class="o">);</span>
</span><span class='line'> <span class="n">matrix</span><span class="o">.</span><span class="na">setElement</span><span class="o">(</span><span class="mi">1</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="n">sinAngle</span><span class="o">);</span>
</span><span class='line'> <span class="n">matrix</span><span class="o">.</span><span class="na">setElement</span><span class="o">(</span><span class="mi">2</span><span class="o">,</span> <span class="mi">1</span><span class="o">,</span> <span class="o">-</span><span class="n">sinAngle</span><span class="o">);</span>
</span><span class='line'> <span class="n">matrix</span><span class="o">.</span><span class="na">setElement</span><span class="o">(</span><span class="mi">2</span><span class="o">,</span> <span class="mi">2</span><span class="o">,</span> <span class="n">cosAngle</span><span class="o">);</span>
</span><span class='line'>
</span><span class='line'> <span class="c1">// Apply rotation</span>
</span><span class='line'> <span class="n">transformation</span><span class="o">.</span><span class="na">multiply</span><span class="o">(</span><span class="n">matrix</span><span class="o">);</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>类中的每个方法之间前后要有空行</li>
<li>变量的声明要左对齐</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="n">TextFile</span> <span class="n">file</span><span class="o">;</span>
</span><span class='line'> <span class="kt">int</span> <span class="n">nPoints</span><span class="o">;</span>
</span><span class='line'> <span class="kt">double</span> <span class="n">x</span><span class="o">,</span> <span class="n">y</span><span class="o">;</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>语句之间也要对齐</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'> <span class="k">if</span> <span class="o">(</span><span class="n">a</span> <span class="o">==</span> <span class="n">lowValue</span><span class="o">)</span> <span class="n">compueSomething</span><span class="o">();</span>
</span><span class='line'> <span class="k">else</span> <span class="nf">if</span> <span class="o">(</span><span class="n">a</span> <span class="o">==</span> <span class="n">mediumValue</span><span class="o">)</span> <span class="n">computeSomethingElse</span><span class="o">();</span>
</span><span class='line'> <span class="k">else</span> <span class="nf">if</span> <span class="o">(</span><span class="n">a</span> <span class="o">==</span> <span class="n">highValue</span><span class="o">)</span> <span class="n">computeSomethingElseYet</span><span class="o">();</span>
</span><span class='line'>
</span><span class='line'> <span class="n">value</span> <span class="o">=</span> <span class="o">(</span><span class="n">potential</span> <span class="o">*</span> <span class="n">oilDensity</span><span class="o">)</span> <span class="o">/</span> <span class="n">constant1</span> <span class="o">+</span>
</span><span class='line'> <span class="o">(</span><span class="n">depth</span> <span class="o">*</span> <span class="n">waterDensity</span><span class="o">)</span> <span class="o">/</span> <span class="n">constant2</span> <span class="o">+</span>
</span><span class='line'> <span class="o">(</span><span class="n">zCoordinateValue</span> <span class="o">*</span> <span class="n">gasDensity</span><span class="o">)</span> <span class="o">/</span> <span class="n">constant3</span><span class="o">;</span>
</span><span class='line'>
</span><span class='line'> <span class="n">minPosition</span> <span class="o">=</span> <span class="n">computeDistance</span><span class="o">(</span><span class="n">min</span><span class="o">,</span> <span class="n">x</span><span class="o">,</span> <span class="n">y</span><span class="o">,</span> <span class="n">z</span><span class="o">);</span>
</span><span class='line'> <span class="n">averagePosition</span> <span class="o">=</span> <span class="n">computeDistance</span><span class="o">(</span><span class="n">average</span><span class="o">,</span> <span class="n">x</span><span class="o">,</span> <span class="n">y</span><span class="o">,</span> <span class="n">z</span><span class="o">);</span>
</span><span class='line'>
</span><span class='line'> <span class="k">switch</span> <span class="o">(</span><span class="n">phase</span><span class="o">)</span> <span class="o">{</span>
</span><span class='line'> <span class="k">case</span> <span class="n">PHASE_OIL</span> <span class="o">:</span> <span class="n">text</span> <span class="o">=</span> <span class="s">&quot;Oil&quot;</span><span class="o">;</span> <span class="k">break</span><span class="o">;</span>
</span><span class='line'> <span class="k">case</span> <span class="n">PHASE_WATER</span> <span class="o">:</span> <span class="n">text</span> <span class="o">=</span> <span class="s">&quot;Water&quot;</span><span class="o">;</span> <span class="k">break</span><span class="o">;</span>
</span><span class='line'> <span class="k">case</span> <span class="n">PHASE_GAS</span> <span class="o">:</span> <span class="n">text</span> <span class="o">=</span> <span class="s">&quot;Gas&quot;</span><span class="o">;</span> <span class="k">break</span><span class="o">;</span>
</span><span class='line'> <span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<h3>注释</h3>
<ul>
<li>代码应该能够自我解释。复杂的代码要考虑重写</li>
<li>Javadoc的注释使用下面的格式,可以通过工具生成,块注释每行的开头要有*号</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="cm">/**</span>
</span><span class='line'><span class="cm"> * Return lateral location of the specified position.</span>
</span><span class='line'><span class="cm"> * If the position is unset, NaN is returned.</span>
</span><span class='line'><span class="cm"> *</span>
</span><span class='line'><span class="cm"> * @param x X coordinate of position.</span>
</span><span class='line'><span class="cm"> * @param y Y coordinate of position.</span>
</span><span class='line'><span class="cm"> * @param zone Zone of position.</span>
</span><span class='line'><span class="cm"> * @return Lateral location.</span>
</span><span class='line'><span class="cm"> * @throws IllegalArgumentException If zone is &lt;= 0.</span>
</span><span class='line'><span class="cm"> */</span>
</span><span class='line'><span class="kd">public</span> <span class="kt">double</span> <span class="nf">computeLocation</span><span class="o">(</span><span class="kt">double</span> <span class="n">x</span><span class="o">,</span> <span class="kt">double</span> <span class="n">y</span><span class="o">,</span> <span class="kt">int</span> <span class="n">zone</span><span class="o">)</span>
</span><span class='line'> <span class="kd">throws</span> <span class="n">IllegalArgumentException</span>
</span><span class='line'><span class="o">{</span>
</span><span class='line'> <span class="o">...</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>在注释后面要有空格,注释要跟着代码缩进</li>
</ul>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="c1">// This is a comment NOT: //This is a comment</span>
</span><span class='line'>
</span><span class='line'><span class="cm">/** NOT: /**</span>
</span><span class='line'><span class="cm"> * This is a javadoc *This is a javadoc</span>
</span><span class='line'><span class="cm"> * comment *comment</span>
</span><span class='line'><span class="cm"> */</span> <span class="o">*/</span>
</span><span class='line'>
</span><span class='line'><span class="k">while</span> <span class="o">(</span><span class="kc">true</span><span class="o">)</span> <span class="o">{</span> <span class="c1">// NOT: while (true) { </span>
</span><span class='line'> <span class="c1">// Do something // Do something</span>
</span><span class='line'> <span class="n">something</span><span class="o">();</span> <span class="n">something</span><span class="o">();</span>
</span><span class='line'><span class="o">}</span>
</span></code></pre></td></tr></table></div></figure>
<p></p>
<ul>
<li>所有公开的类和接口应该使用Javadoc的注释规范</li>
</ul>
<h3>References</h3>
<p>[1] Code Complete, Steve McConnel &ndash; Microsoft Press</p>
<p>[2] Java Code Conventions
<a href="http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html">http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html</a></p>
<p>[3] Netscape&rsquo;s Software Coding Standards for Java
<a href="http://developer.netscape.com/docs/technote/java/codestyle.html">http://developer.netscape.com/docs/technote/java/codestyle.html</a></p>
<p>[4] C / C++ / Java Coding Standards from NASA
<a href="http://v2ma09.gsfc.nasa.gov/coding_standards.html">http://v2ma09.gsfc.nasa.gov/coding_standards.html</a></p>
<p>[5] Coding Standards for Java from AmbySoft
<a href="http://www.ambysoft.com/javaCodingStandards.html">http://www.ambysoft.com/javaCodingStandards.html</a></p>
</div>
<div class="meta">
<span class="comments"><a href="/blog/2014/10/09/java-programming-guide//index.html#disqus_thread">Comments</a></span>
</div>
</article>
<article class="post">
<h2 class="title">
<a href="/blog/2014/10/08/naming-variables/">
变量命名概要</a>
</h2>
<div class="entry-content">
<div class="meta">
<div class="date">Published on:
<time datetime="2014-10-08T22:22:05+08:00" pubdate data-updated="true">Oct 8<sup>th</sup>, 2014</time></div>
<div class="tags">
Tag:
<a href='/blog/tags/code-complete/'>code-complete</a>
</div>
</div>
<h2>变量命名</h2>
<h3>命名的一般注意事项</h3>
<ul>
<li>名字是否完整的表达了变量所代表的含义</li>
<li>名字是否足够长,让人一看就懂</li>
<li>名字反映了现实世界中的问题,而不是编程语言中的解决方案</li>
<li>如果有计算值限定符,它们是否被放在了后面 employCount employTotal</li>
<li>是否使用Count和Index来代替Num</li>
</ul>
<h3>为特定的数据类型命名</h3>
<ul>
<li>循环下标的命名有意义吗?(如果是多层嵌套要注意下标的命名)</li>
<li>所有的临时变量都重新命名以更有意义</li>
<li>当布尔变量为真时,变量名能准确表达其意义</li>
<li>枚举类型的命名是否使用了前缀<code>Color_Red</code> <code>Color_Blue</code></li>
<li>具名常量根据其代表的实体,而不是它所代表的数字来命名</li>
</ul>
<h3>命名规则</h3>
<ul>
<li>规则能够区分全局数据,类数据,和局部数据吗?</li>
<li>规则能够区分类型名,具名常量,枚举类型和变量名吗? 如类型名用大小写混合,具名常量用全部大写</li>
<li>规则能够区分子程序的输入和输出参数吗?</li>
<li>规则尽可能的与语言规则标准兼容吗?</li>
</ul>
<h3>短名字</h3>
<ul>
<li>除非有必要才用短名字</li>
<li>是否避免了为了节省一个字而缩写的情况</li>
<li>所有单词的缩写方式都一致吗</li>
<li>名字能够读出来吗</li>
<li>避免容易看错和读错的名字了吗? 如i 1 l, o 0 O等</li>
<li>在缩写表里有对缩写进行说明吗</li>
</ul>
<h3>常见的命名问题</h3>
<ul>
<li>容易让人误解的名字</li>
<li>有相近含义的名字</li>
<li>只有一两个字符不同的名字</li>
<li>发音相近的名字</li>
<li>包含数字的名字</li>
<li>英语中经常拼错的名字</li>
<li>与标准的子程序或预定义的变量名冲突的名字</li>
<li>过于随意的名字</li>
<li>含有难读字符的名字</li>
</ul>
<h3>要点</h3>
<ul>
<li>名字要尽可能的具体。那些模糊的或者太通用的可以包含多种用途的名字通常都不是很好</li>
<li>现代编程语言很少需要用到缩写</li>
<li>代码阅读的次数要远多于编写的次数</li>
<li>命名规则应该能够很好的区分全局数据,局部数据,类数据。它们还应该区分类型名,具名常量,枚举类型和变量名</li>
</ul>
</div>
<div class="meta">
<span class="comments"><a href="/blog/2014/10/08/naming-variables//index.html#disqus_thread">Comments</a></span>
</div>
</article>
<article class="post">
<h2 class="title">
<a href="/blog/2014/09/25/lnk2001-unresolved-external-symbol-imp-gettickcount64-at-0/">
LNK2001: Unresolved External Symbol __imp__GetTickCount64@0</a>
</h2>
<div class="entry-content">
<div class="meta">
<div class="date">Published on:
<time datetime="2014-09-25T22:16:46+08:00" pubdate data-updated="true">Sep 25<sup>th</sup>, 2014</time></div>
<div class="tags">
Tag:
<a href='/blog/tags/compile/'>compile</a>
</div>
</div>
<p>这个链接错误的发生在链接MSVCRT.lib时,原因是链接了的错误版本kernel32.lib等库。修改link条件,把/LIBPATH:&ldquo;libpath&#8221;这个改为正确的path就可以了。如果自己写makefile文件,在使用编译器,链接器,头文件,和库时,要特别小心。如果使用了第三方的库要看这个第三方的库是用什么版本的CRT(运行时库)编译的,是多线程版的还是单线程版的,用Unicode的还是ASCII的。</p>
<p><strong>LINK : fatal error LNK1101: incorrect MSPDB80.DLL version;</strong> 这个错误是在使用cl.exe命令行编译时出现的错误,原因是VC\Bin\下没有“msobj80.dll,mspdb80.dll,mspdbcore.dll,mspdbsrv.exe”这四个文件。
解决的方法:</p>
<ul>
<li>直接从Common7\IDE\下复制这四个文件到VC\Bin\下即可解决</li>
<li>添加系统变量(Path),这样:我的电脑->属性->高级->环境变量->系统变量,在path中添加C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;,注意结尾最后用“;”隔开!</li>
</ul>
<p>附注:</p>
<blockquote><p>RUN-TIME LIBRARYRun-Time Library是编译器提供的标准库,提供一些基本的库函数和系统调用。
我们一般使用的Run-Time Library是C Run-Time Libraries。当然也有Standard C++ libraries。</p>
<p>C Run-Time Libraries实现ANSI C的标准库。VC安装目录的CRT目录有C Run-Time库的大部分源代码。 C Run-Time Libraries有静态库版本,也有动态链接库版本;有单线程版本,也有多线程版本;还有调试和非调试版本。</p>
<p>动态链接库版本:/MD Multithreaded DLL 使用导入库MSVCRT.LIB</p>
<p>/MDd Debug Multithreaded DLL 使用导入库MSVCRTD.LIB</p>
<p>静态库版本:/ML Single-Threaded 使用静态库LIBC.LIB</p>
<p>/MLd Debug Single-Threaded 使用静态库LIBCD.LIB</p>
<p>/MT Multithreaded 使用静态库LIBCMT.LIB</p>
<p>/MTd Debug Multithreaded 使用静态库LIBCMTD.LIB</p>
<p>若要使用其中的一个运行时库 请忽略其他库:</p>
<ul>
<li>libc.lib 单线程 libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib</li>
<li>libcmt.lib 多线程 libc.lib、msvcrt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib</li>
<li>msvcrt.lib 使用多线程 DLL libc.lib、libcmt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib</li>
<li>libcd.lib 单线程调试 libc.lib、libcmt.lib、msvcrt.lib、libcmtd.lib、msvcrtd.lib</li>
<li>libcmtd.lib 多线程调试 libc.lib、libcmt.lib、msvcrt.lib、libcd.lib、msvcrtd.lib</li>
<li>msvcrtd.lib 使用多线程调试 DLL libc.lib、libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib</li>
</ul>
<p>设置方法:属性,链接器,输入,忽略指定库 libc.lib、libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib (使用一个,忽略其他的)</p></blockquote>
<p>[1] 引用<a href="http://www.hz601.org/heaven/">http://www.hz601.org/heaven/</a></p>
</div>
<div class="meta">
<span class="comments"><a href="/blog/2014/09/25/lnk2001-unresolved-external-symbol-imp-gettickcount64-at-0//index.html#disqus_thread">Comments</a></span>
</div>
</article>
<nav id="pagenavi">
<a href="page2" class="next">Next</a>
<div class="center"><a href="/blog/archives">Blog Archives</a></div>
</nav>
</div>
<div class="share">
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid="></script>
<script type="text/javascript" src="http://china-addthis.googlecode.com/svn/trunk/addthis.js" charset="UTF-8"></script><span class="addthis_org_cn"><a href="http://addthis.org.cn/share/" i="0|1|31|22|28|42|48|49|21|2|43" title="收藏&amp;分享"><img src="http://addthis.org.cn/images/a2.gif" alt="分享家:Addthis中文版" align="absmiddle" /></a></span>
</div>
<aside class="sidebar">
<section>
<h1>Tag Cloud</h1>
<span id="tag-cloud"><embed type='application/x-shockwave-flash' src='/javascripts/tagcloud.swf'width='100%' height='250' bgcolor='#f2f2f2' id='tagcloudflash' name='tagcloudflash' quality='high' allowscriptaccess='always'flashvars="tcolor=0x333333&amp;tcolor2=0x333333&amp;hicolor=0x000000&amp;tspeed=100&amp;distr=true&amp;mode=tags&amp;tagcloud=%3Ctags%3E%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Falgorithm%27+style%3D%27font-size%3A+18.88888888888889%25%27%3Ealgorithm%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Farchitecture%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Earchitecture%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fbuddha%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Ebuddha%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fbuild%27+style%3D%27font-size%3A+18.88888888888889%25%27%3Ebuild%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fcode-complete%27+style%3D%27font-size%3A+32.22222222222222%25%27%3Ecode-complete%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fcompile%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Ecompile%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fcompile%27+style%3D%27font-size%3A+14.444444444444445%25%27%3ECompile%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fdebug%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Edebug%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fessay%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Eessay%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fgit%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Egit%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fgithub%27+style%3D%27font-size%3A+23.333333333333336%25%27%3EGithub%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fjni%27+style%3D%27font-size%3A+23.333333333333336%25%27%3EJNI%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Flive%27+style%3D%27font-size%3A+27.77777777777778%25%27%3ELive%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fmarkdown%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Emarkdown%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Foctopress%27+style%3D%27font-size%3A+23.333333333333336%25%27%3Eoctopress%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fopengl%27+style%3D%27font-size%3A+50.0%25%27%3Eopengl%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fprogramming%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Eprogramming%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fthinking%27+style%3D%27font-size%3A+27.77777777777778%25%27%3EThinking%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Ftools%27+style%3D%27font-size%3A+18.88888888888889%25%27%3Etools%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fvim%27+style%3D%27font-size%3A+23.333333333333336%25%27%3Evim%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fwindows%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Ewindows%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fwish%27+style%3D%27font-size%3A+14.444444444444445%25%27%3Ewish%3C%2Fa%3E+%3Ca+href%3D%27http%3A%2F%2Fsweetdark.github.com%2Fblog%2Ftags%2Fzen%27+style%3D%27font-size%3A+18.88888888888889%25%27%3Ezen%3C%2Fa%3E+%3C%2Ftags%3E"></span>
</section>
</aside>
</div>
<footer id="footer">
<div style="display:inline">
Copyright &copy; 2014
Mario
. Powered by <a href="http://octopress.org">Octopress</a> |
Theme <a href="http://github.com/panks/fabric">fabric</a> by <a href="http://panks.me">Pankaj Kumar</a>
</div>
</footer>
<script src="/javascripts/fabric.js"></script>
<script src="/javascripts/jquery.fancybox.pack.js"></script>
<script type="text/javascript">
(function($){
$('.fancybox').fancybox();
})(jQuery);
</script> <!-- Delete or comment this line to disable Fancybox -->
<script type="text/javascript">
var disqus_shortname = 'sweetdark';
var disqus_script = 'count.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
<!-- end toload -->
</div>
</div>
<script src="/javascripts/jquery.ui.totop.js" type="text/javascript"></script>
<script type="text/javascript">
/*<![CDATA[*/
;(function($){$().UItoTop({easingType:'easeOutCirc'});})(jQuery);
/*]]>*/
</script><!-- remove it to remove the scroll to top button -->
</body>
</html>