Comparing Constant Strings with String Variables
To avoid problems, you should never compare a string variable with a string constant, because string variables may have a null value, in which case your code will throw a NullPointerException. Here's an example:
String strName = null;
strName = getName(); //some call which retrives name from DB
if(strName.equals("Ritesh Patel")) {
// some processing.
}
The preceding example might raise an exception if the result of the getName() call returns null. Instead, to be safe, always make the comparison the other way around—by comparing the string constant with the string variable:
String strName = null;
strName = getName();
if("Ritesh Patel".equals(strName)) {
// some processing.
}
Following this rule will help you avoid unnecessary NullPointerExceptions and abnormal program termination.
By - Bavanandan
List of J2EE Patterns Catalog
Below is the list of available J2EE Patterns and their description
Business Delegate
Reduce coupling between Web and Enterprise JavaBeans TM tiers
Composite Entity
Model a network of related business entities
Composite View
Separately manage layout and content of multiple composed views
Data Access Object (DAO)
Abstract and encapsulate data access mechanisms
Fast Lane Reader
Improve read performance of tabular data
Front Controller
Centralize application request processing
Intercepting Filter
Pre- and post-process application requests
Model-View-Controller
Decouple data representation, application behavior, and presentation
Service Locator
Simplify client access to enterprise business services
Session Facade
Coordinate operations between multiple business objects in a workflow
Transfer Object
Transfer business data between tiers
Value List Handler
Efficiently iterate a virtual list
View Helper
Simplify access to model state and data access logic
By - Feizal
Java Design Patterns
Abstract: “Pattern” as the name suggests, means series of events occurring in a definite order. The patterns can be found in Java and J2ee technologies also. Many a times, we find that there is a particular way of tackling a problem. This way is easy and has been used many times successfully by a number of people earlier also. This method becomes a pattern.
Creational Patterns
There are five types of Creational Patterns.
1. Factory Pattern
2. Abstract Factory Pattern
3. Builder Pattern
4. Prototype Pattern
5. Singleton Pattern
Structural Patterns
Structural Patterns describe how objects and classes can be combined to form larger structures. The difference between class patterns and object patterns is that class patterns describe abstraction with the help of inheritance and how it can be used to provide more useful program interface. Object patterns, on other hand, describe how objects can be associated and composed to form larger, more complex structures.
There are seven structural patterns described. They are as follows:
Patterns.
1. Adapter Pattern
2. Bridge Pattern
3. Composite Pattern
4. Decorator Pattern
5. Facade Pattern
6. Flyweight Pattern
7. Proxy Pattern
Behavioral Patterns
Behavioral patterns are those which are concerned with interactions between the objects. The interactions between the objects should be such that they are talking to each other and still are loosely coupled. The loose coupling is the key to n-tier architectures. In this, the implementation and the client should be loosely coupled in order to avoid hard-coding and dependencies.
The behavioral patterns are:
1. Chain of Resposibility Pattern
2. Command Pattern
3. Interpreter Pattern
4. Iterator Pattern
5. Mediator Pattern
6. Momento Pattern
7. Observer Pattern
8. State Pattern
9. Strategy Pattern
10. Template Pattern
11. Visitor Pattern
By - Amaresh
Please find more topics under JASe Archive!!!
Tuesday, September 15, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment