代码改变世界

阅读排行榜

Effective Java 78 Consider serialization proxies instead of serialized instances

2014-05-12 08:39 by 小郝(Kaibo Hao), 492 阅读, 收藏,
摘要: 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 C# 学习笔记(四十七)对异常进行strong guarantee 策略处理

2011-08-06 22:13 by 小郝(Kaibo Hao), 488 阅读, 收藏,
摘要: 异常处理的三种策略:Basic guarantee:在抛出异常前,保证所有资源没有溢出,而且各个对象属性状态是合法状态; Strong guarantee:基于Basic guarantee,其强调对象的属性状态还原为失败修改前的状态。(该策略确保了从异常中修复和简化异常处理操作); No throw Exception guarantee:在方法中不抛出异常,所有的错误都在该方法中处理。 阅读全文

Effective Java 66 Synchronize access to shared mutable data

2014-04-30 23:53 by 小郝(Kaibo Hao), 487 阅读, 收藏,
摘要: When multiple threads share mutable data, each thread that reads or writes the data must perform synchronization. Without synchronization, there is no guarantee that one thread’s changes will be visible to another. The penalties for failing to synchronize shared mutable data are liveness and safety failures. If you need only inter-thread communication, and not mutual exclusion, the volatile modifier is an acceptable form of synchronization, but it can be tricky to use correctly. 阅读全文

Effective Java 35 Prefer annotations to naming patterns

2014-03-29 22:25 by 小郝(Kaibo Hao), 487 阅读, 收藏,
摘要: There is simply no reason to use naming patterns now that we have annotations. All programmers should, however, use the predefined annotation types provided by the Java platform(Items 36 and Item24). 阅读全文

Effective Java 36 Consistently use the Override annotation

2014-03-30 12:35 by 小郝(Kaibo Hao), 486 阅读, 收藏,
摘要: The compiler can protect you from a great many errors if you use the Override annotation on every method declaration that you believe to override a supertype declaration, with one exception. In concrete classes, you need not annotate methods that you believe to override abstract method declarations(though it is not harmful to do so). 阅读全文

Effective Java 42 Use varargs judiciously

2014-04-05 18:21 by 小郝(Kaibo Hao), 484 阅读, 收藏,
摘要: Varargs methods are a convenient way to define methods that require a variable number of arguments, but they should not be overused. They can produce confusing results if used inappropriately. 阅读全文

Effective Java 53 Prefer interfaces to reflection

2014-04-16 13:28 by 小郝(Kaibo Hao), 483 阅读, 收藏,
摘要: Reflection is a powerful facility that is required for certain sophisticated system programming tasks, but it has many disadvantages. If you are writing a program that has to work with classes unknown at compile time, you should, if at all possible, use reflection only to instantiate objects, and access the objects using some interface or superclass that is known at compile time. 阅读全文

Effective C# 学习笔记(三十八)理解Dynamic的得与失

2011-07-28 22:35 by 小郝(Kaibo Hao), 483 阅读, 收藏,
摘要: Dynamic是C#4.0新增的特性,其可以使我们完成一些在运行时的动态类型逻辑定义。但是其是一把双刃剑,在带来动态特性以应付多变处理需求的同时,也带来了更多需要校验处理的地方,不能在编译时发现程序的漏洞。而且在运行时由于对类型转换的相关处理,要比静态类型处理逻辑更费资源和时间。 阅读全文

Effective Java 65 Don't ignore exceptions

2014-04-29 21:12 by 小郝(Kaibo Hao), 480 阅读, 收藏,
摘要: The advice in this item applies equally to checked and unchecked exceptions. Whether an exception represents a predictable exceptional condition or a programming error, ignoring it with an empty catch block will result in a program that continues silently in the face of error. The program might then fail at an arbitrary time in the future, at a point in the code that bears no apparent relation to the source of the problem. Properly handling an exception can avert failure entirely. Merely letting 阅读全文

NHibernate学习笔记(4)—使用存储过程

2009-10-07 17:40 by 小郝(Kaibo Hao), 480 阅读, 收藏,
摘要: 继续NHibernate学习笔记,这次说说存储过程的使用,在看完这篇文章后试了试,有两个要注意的地方1. 这篇文章NHibernate之旅(15):探索NHibernate中使用存储过程(上)(new!)中的删除示例要对一个有关系的表的数据进行删除操作,这时要先确认该关系的字段是级联删除的,否则会报错,设置如下:在创建对象的存储过程中,要注意我们的Customer表采用了自增ID的方式,要注意如下... 阅读全文
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 21 下一页