design patterns used in core java (j2se) source code
October 9, 2012 Leave a comment
These are some of the design patterns used in core java API that I have gone through in my experience:
Decorator and Bridge patterns – java.io
Observer pattern is available as standard API
Iterator Pattern – All collection classes
Template Pattern – Arrays.sort() and Collection.sort()
Singleton Pattern – Runtime, Calendar
Factory Pattern – Wrappers of primitive data type’s valueOf methods [Integer.valueOf()]
Other most commonly used patterns:
Decorator: Java IO
Strategy Pattern: If you’ve ever used dependency injection, you’ve used the strategy pattern.
Facade: Any service APIs implement this pattern.
Singleton: Used in caching
Builder: While Writing Unit Tests
Prototype: Cloning
Adapter: asList , toString
Chain Of Responsibility: Logging
Factory: Action Mapping
MVC: Web frameworks
Proxy: Web services
Template
Recent Comments