代码改变世界

JavaScript Patterns 2.9 Coding Conventions

2014-05-24 23:07 by 小郝(Kaibo Hao), 317 阅读, 0 推荐, 收藏, 编辑
摘要:It’s important to establish and follow coding conventions—they make your code consistent, predictable, and much easier to read and understand. A new developer joining the team can read through the conventions and be productive much sooner, understanding the code written by any other team member. 阅读全文

JavaScript Patterns 2.8 Number Conversions with parseInt()

2014-05-23 12:28 by 小郝(Kaibo Hao), 292 阅读, 0 推荐, 收藏, 编辑
摘要:This post introduces how to deal with Number Conversions with parseInt(). 阅读全文

JavaScript Patterns 2.7 Avoiding Implied Typecasting

2014-05-22 23:29 by 小郝(Kaibo Hao), 263 阅读, 0 推荐, 收藏, 编辑
摘要:This post introduces how to use the ===, eval, Function() carefully. 阅读全文

JavaScript Patterns 2.6 switch Pattern

2014-05-21 22:03 by 小郝(Kaibo Hao), 280 阅读, 0 推荐, 收藏, 编辑
摘要:This post introduces the principle of the use of switch-pattern. 阅读全文

JavaScript Patterns 2.5 (Not) Augmenting Build-in Prototypes

2014-05-20 13:36 by 小郝(Kaibo Hao), 339 阅读, 0 推荐, 收藏, 编辑
摘要:Other developers using your code will probably expect the built-in JavaScript methods to work consistently and will not expect your additions. And properties you add to the prototype may show up in loops that don't use hasOwnProperty(), so they can create confusion.Please be cautious of Augmenting Build-in Prototypes. 阅读全文

JavaScript Patterns 2.4 For-in loop

2014-05-19 11:06 by 小郝(Kaibo Hao), 332 阅读, 0 推荐, 收藏, 编辑
摘要:Enumeration should be used to iterate over nonarray objects. It's important to use the method hasOwnProperty()when iterating over object properties to filter out properties that come down the prototype chain. 阅读全文

JavaScript Patterns 2.3 For loops

2014-05-17 10:14 by 小郝(Kaibo Hao), 271 阅读, 0 推荐, 收藏, 编辑
摘要:Do you know how to write the for-loop efficiently? Read this to get it. :) 阅读全文

Java Concurrency In Practice -Chapter 2 Thread Safety

2014-05-16 20:03 by 小郝(Kaibo Hao), 335 阅读, 0 推荐, 收藏, 编辑
摘要:This post introduces the challenge and related solution (Atomic, Locks) on Thread Safety. 阅读全文

JavaScript Patterns 2.2 Minimizing Globals

2014-05-15 23:14 by 小郝(Kaibo Hao), 333 阅读, 0 推荐, 收藏, 编辑
摘要:This blog post introduces the problem with Globals, Side Effect when Forgetting var, Access the Global Object, Single var Pattern and Hoisting: A problem with Scattered vars. 阅读全文

Java Concurrency In Practice - Chapter 1 Introduction

2014-05-14 23:15 by 小郝(Kaibo Hao), 237 阅读, 0 推荐, 收藏, 编辑
摘要:A brief introduction on why to introduce Multiple treads application and its features. 阅读全文

JavaScript Patterns 2.1 Writing Maintainable Code

2014-05-14 22:11 by 小郝(Kaibo Hao), 268 阅读, 0 推荐, 收藏, 编辑
摘要:Maintainable code means code that: is readable, consistent, predictable, Looks as if it was written by the same person and documented. 阅读全文

JavaScript Patterns 1 Introduction

2014-05-13 08:00 by 小郝(Kaibo Hao), 308 阅读, 0 推荐, 收藏, 编辑
摘要:Introduction of the JavaScript patterns such as Object-Oriented, No Classes, Prototypes, Environment. And some others related standard and tools such as ECMAScript 5, JSLint and fire bug . 阅读全文

Effective Java Index

2014-05-12 09:04 by 小郝(Kaibo Hao), 915 阅读, 0 推荐, 收藏, 编辑
摘要:Hi guys, I am happy to tell you that I am moving to the open source world. And Java is the 1st language I have chosen for this migration. It's a nice chance to read some great books like "Effective Java 2nd Edition" and share the note for what I learned from it with you just as what I did before with CSharp. Here is the index of the notes. Hope you like it :) 阅读全文

Effective Java 78 Consider serialization proxies instead of serialized instances

2014-05-12 08:39 by 小郝(Kaibo Hao), 472 阅读, 0 推荐, 收藏, 编辑
摘要:Consider the serialization proxy pattern whenever you find yourself having to write a readObject or writeObject method on a class that is not extendable by its clients. This pattern is perhaps the easiest way to robustly serialize objects with nontrivial invariants. 阅读全文

Effective Java 77 For instance control, prefer enum types to readResolve

2014-05-11 20:40 by 小郝(Kaibo Hao), 455 阅读, 0 推荐, 收藏, 编辑
摘要:You should use enum types to enforce instance control invariants wherever possible. If this is not possible and you need a class to be both serializable and instance-controlled, you must provide a readResolve method and ensure that all of the class's instance fields are either primitive or transient. 阅读全文

Effective Java 76 Write readObject methods defensively

2014-05-10 15:20 by 小郝(Kaibo Hao), 556 阅读, 0 推荐, 收藏, 编辑
摘要:Anytime you write a readObject method, adopt the mind-set that you are writing a public constructor that must produce a valid instance regardless of what byte stream it is given. Do not assume that the byte stream represents an actual serialized instance. 阅读全文

Effective Java 75 Consider using a custom serialized form

2014-05-09 07:39 by 小郝(Kaibo Hao), 457 阅读, 0 推荐, 收藏, 编辑
摘要:when you have decided that a class should be serializable (Item 74), think hard about what the serialized form should be. Use the default serialized form only if it is a reasonable description of the logical state of the object; otherwise design a custom serialized form that aptly describes the object. You should allocate as much time to designing the serialized form of a class as you allocate to designing it 阅读全文

Effective Java 74 Implement Serializable judiciously

2014-05-08 22:25 by 小郝(Kaibo Hao), 496 阅读, 0 推荐, 收藏, 编辑
摘要:Unless a class is to be thrown away after a short period of use, implementing Serializable is a serious commitment that should be made with care. Extra caution is warranted if a class is designed for inheritance. For such classes, an intermediate design point between implementing Serializable and prohibiting it in subclasses is to provide an accessible parameterless constructor. This design point permits, but does not require, subclasses to implement Serializable. 阅读全文

Effective Java 73 Avoid thread groups

2014-05-07 07:42 by 小郝(Kaibo Hao), 544 阅读, 0 推荐, 收藏, 编辑
摘要:Thread groups don't provide much in the way of useful functionality, and much of the functionality they do provide is flawed. Thread groups are best viewed as an unsuccessful experiment, and you should simply ignore their existence. If you design a class that deals with logical groups of threads, you should probably use thread pool executors (Item 68). 阅读全文

Effective Java 72 Don't depend on the thread scheduler

2014-05-06 08:52 by 小郝(Kaibo Hao), 506 阅读, 0 推荐, 收藏, 编辑
摘要:Do not depend on the thread scheduler for the correctness of your program. The resulting program will be neither robust nor portable. As a corollary, do not rely on Thread.yield or thread priorities. These facilities are merely hints to the scheduler. Thread priorities may be used sparingly to improve the quality of service of an already working program, but they should never be used to "fix" a program that barely works. 阅读全文
上一页 1 2 3 4 5 6 7 ··· 11 下一页