As simple as possible and no simpler -Einstein Life is like a snowball. The important thing is finding wet snow and a really long hill. -Warren Buffett Work expands so as to fill the time available for its completion -Parkinson's Law
The process areas of Human Resource Management are: Develop Human Resource Plan; Acquire Project Team, Develop Project Team and Manage Project Team. Develop Human Resource Plan Roles & Responsibilities matrix(Responsible, Accountable, Supports, Informed, Consulted), Organization Chart, Staffing Management Plan Acquire Team Four kinds of "Relationship Styles": Socializer, Relater, Thinker, Director Develop Team Situational Leadship Styles: Telling, Selling, Participative, Delegating Manage Team Virtual Teams The Death Spiral Globe Cultural Expectations
checked 和 unchecked exception 的区别,资深一点的Java程序员都知道。这里我感兴趣的是该怎么用checked 和 unchecked exception. 最早的exception处理机制来自C++,在C中为了避免错误,我们会根据返回结果或者判断状态(文件操作)来保证程序的正确性。这样在代码中就会有大量的if/else判断最后甚至让读代码的人忘了程序片段的真正意图。因此C++中引入了exception的处理机制。不过C++为了兼容C,异常处理是选择性的。 Java是真正严格实现异常机制的语言。 从架构的角度什么时候用checked exception,什么时候用unchecked exception, 如何封装,处理,仁者见仁,智者见智。 有种选择是不用checked exception. Think In Java作者Bruce Eckel在Does Java need Checked Exceptions 提到这种设计选择。我的理解是原因有三点: 业务逻辑不愿意恢复的错误,比如Rod Johnson在J2EE Deveopment Without EJB中举了一个Service Locator 中JNDI Lookup failure时直接抛出Un-Checked exception。这样不会逼着系统处理这种异常,比如尝试恢复或者提示用户。 checked exception是编译时异常,强制要求处理,确实降低了程序出错的可能。但有时程序中还是大量充斥这种异常处理的代码。 程序员经常有意无意中丢掉了异常(简单的打印出异常信息,没有思考如何进一步处理),这是程序中引入bug的一种主要来源,并且比较难找。 据说Spring中DAO的封装中都是Runtime Exception. 不知是不是也是基于此考虑。
一直不是很理解这三个感念之间的区别。Java是面向对象的编程语言,这点与现在流行的面向函数的动态编程语言不同。Javascript就是后者的一个例子。函数可以独立于对象存在,(或者说它本身就是一种对象)。 Java里没有函数指针,但可以向函数中传入一个匿名内部类模拟这种行为。 Java目前还未引入closures, 但基于JVM的Groovy已经有Closures概念。在Groovy中,所谓Closures就是一段大括号括起来的代码段。这段代码按照Java的习惯一般只能存在于函数中(初始化代码除外)并以函数名的方式调用。在Groovy中,这段代码可以赋给一个变量,通过这个变量来调用这段代码(很多时候放在大括号中直接匿名使用)。 那么代码段与Closures的区别是什么呢? 代码段一般是虚拟机碰到这段代码时就执行(方法调用,初始化,回调方法)。Closures只有在它的call()方法被调用时才执行。理解的不是很清楚,详细请参考:Closures Informal Guide 闭包有几个特点: 可以访问闭包范围外的变量(这点是不是跟Java中内部类相似?) 可以匿名用在任何允许用闭包的地方,比如Groovy的list的collect, each 调用中
oracle Hints select /*+ FIRST_ROWS(100) */ field1, field2,... from ... where ... 上面是Hints, 用于优化,告诉oracle 尽快返回前100行,适用于OLTP。还有ALL_ROWS,告诉Oracle用最少的资源处理所有行并一次返回。 FTS(全表扫描)可以并行,通过设置 DB_FILE_MULTIBLOCK_READ_COUNT 索引扫描不能并行,一般快些。 Oracle 提供了两种优化策略 一种是 Rule-base Optimizer 另一种是Cost-base Optimizer
类的初始化顺序: 静态初始化块 main函数中的输出(调用构造函数前) 实例的初始化块(初始化匿名内部类的地方) 构造函数初始化 import static java.lang.System.out; public class InitializerDemo { public InitializerDemo() { out.println("in constructor"); // Fourth } static { out.println("in static initializer"); // First } { out.println("in instance initializer"); // Third } public static void main(String[] args) { out.println("in main() method"); //second new InitializerDemo(); } }
在用IFrame做Ajax时,需要考虑的有: 先定义隐藏的IFrame <iframe name="myIframe" src="blank.html" style="width:0px;height:0px" frameborder="0"> </iframe> 通过button,Href或者form提交,动态修改IFrame的src属性或者设置Href,Form的Target属性 如何在父窗口和IFrame页面传递数据 Three ways of Moving Data From an iframe to the Parent The iframe page can use it's own javascripts to transfer and place the data into the parent. <script> // - this is the script in the iframe results page var reps = document.getElementById('state_reps').innerHTML; parent.document.getElementById('results1').innerHTML = reps; </script> The iframe page can pass its document object as an argument to a function in the parent, thereby allowing the parent to retrieve data from the iframe. <script> // - this is the script in parent page function showReps(doc){ var x = doc.getElementById('state_reps').innerHTML; document.getElementById('results2').innerHTML = x; } </script> Place an onload event handler in the iframe tag in the parent document (this page). This method does not work with Netscape <iframe name="repIframe3" src="blank.html" onload="getIframeDoc()"></iframe> <script> function getIframeDoc(){ var iframeDoc = window.frames['repIframe3'].document; var sr = iframeDoc.getElementById('state_reps'); if (sr){ var reps3 = sr.innerHTML; document.getElementById('results3').innerHTML = reps3; } } </script> <script> // - this is the script in the iframe results page parent.showReps(document); </script>
正则表达式 //删除开头和结尾所有的空格 function trim(str) { return str.replace(/(^\s+|\s+$)/g,''); } 注: ^ 开头 $ 结尾 \s 空格匹配 + 多次出现 g 全文匹配 i 忽略大小写 setTimeout(message, 3000); 3秒后执行函数message一次,如果要重复执行需要在message函数中再调用setTimeout一次