michaelljx的博客
michaelljx · 共 10 篇文章
Eliminate unchecked warnings
When you program with generics, you will see many compiler warnings: unchecked cast warnings, unchecked method invocation warnings, unchecked generic array creation warnings, and unchecked conversion warnings. The more experience you acquire with generics, the fewer warnings you’ll get, but don’t e…
2012-01-04 16:34 · Design pattern · 评论(1)
Favor static member classes over nonstatic
One common use of a static member class is as a public helper class, useful only in conjunction with its outer class. For example, consider an enum describing the operations supported by a calculator (Item 30). The Operation enum should be a public static member class of the Calculator class. Clien…
2012-01-04 11:41 · Design pattern · 评论(0)
Minimize the accessibility of classes and members
The rule of thumb is simple: make each class or member as inaccessible as possible. In other words, use the lowest possible access level consistent with the proper functioning of the software that you are writing. For top-level (non-nested) classes and interfaces, there are only two possible access…
2011-12-31 14:07 · Design pattern · 评论(0)
Command vs Strategy
public class ConcreteStrategy implements BaseStrategy { @Override public void execute(Object argument) { // Work with passed-in argument. } } public class ConcreteCommand implements BaseCommand { private Object argument; public ConcreteCommand(Object argument) { this.argument = argument; } @Overrid…
2011-12-16 15:24 · Design pattern · 评论(0)
Tomcat的HttpConnector和HttpProcessor线程交互
The processor thread (the await method) while (!available) { wait(); } Socket socket = this.socket; available = false; notifyAll(); return socket; The connector thread (the assign method) while (available) { wait(); } this.socket = socket; available = true; notifyAll(); Initially, when the "process…
2011-12-16 14:51 · Web · 评论(0)
Tomcat 系统构架(转)
Tomcat 总体结构 Tomcat 的结构很复杂,但是 Tomcat 也非常的模块化,找到了 Tomcat 最核心的模块,您就抓住了 Tomcat 的“七寸”。下面是 Tomcat 的总体结构图: 图 1.Tomcat 的总体结构 从上图中可以看出 Tomcat 的心脏是两个组件:Connector 和 Container,关于这两个组件将在后面详细介绍。Connector 组件是可以被替换,这样可以提供给服务器设计者更多的选择,因为这个组件是如此重要,不仅跟服务器的设计的本身,而且和不同的应用场景也十分相关,所以一 个 Container 可以选择对应多个 Connector。多个 Co…
2011-12-16 11:03 · Web · 评论(0)
Web Tier Design Goals
Web Tier Design Goals Naïve approaches toward J2EE web tier implementation typically result in JSP pages containing excessive amounts of Java scriptlets, with a confused mixture of presentation and business logic. The result is an untestable presentation layer, refactoring headaches, and maintenanc…
2011-12-14 17:35 · Web · 评论(0)
MemcachedClient Configuration(from githun)
You have two options to configure the MemcachedClient: using the app.config, providing an object which implements IMemcachedClientConfiguration App.config (or web.config) is recommended when your pool is static or you rarely change it. Use the programmatic configuration (either implementing the int…
2011-12-13 18:32 · Web · 评论(0)
Strategy Pattern的位置
I'm including an encapsulation hierarchy table of several of the GoF design patterns to help explain the differences between these two patterns. Hopefully it better illustrates what each encapsulates so my explanation makes more sense. First off, the hierarchy lists the scope for which a given patt…
2011-12-12 10:02 · Design pattern · 评论(0)