File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Singleton Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Singleton Pattern" Watch "Singleton Pattern" New topic

Singleton Pattern

Lakshmi siri
Ranch Hand

Joined: Feb 06, 2004
Posts: 44
what is singleton pattern & Vaue Object Pattern?

Venkatesh Chitnis

Joined: Nov 05, 2003
Posts: 9
Hi Lakshmi,

I can answer your question about Singleton Design pattern.
A Singleton Design pattern is meant to instantiate a class only once. In many cases it is absolutely essential to have a unique instance of a class.

Here's one of the ways to implement the Singleton pattern:

class SingletonPattern
// Constructor
protected SingletonPattern()
// Add your code here

private static SingletonPattern instance = null;

public static SingletonPattern getInstance()
if (instance == null)
return new SingletonPattern();
return instance;

This design allows access to the getInstance method, but at the same time does not allow access to the SingletonPattern object.
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Value Object (VO) or Data Transfer Object (DTO) are patterns related on how your data should be transmitted among your application layers.
Bascially, put anything you need into a objetc, wich we'll call the transfer object.

Leandro Melo
SCJP 1.4, SCWCD 1.4
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312

Value Object pattern is used to reduce the network traffic. Consider that you are requesting to get a customer detail from an Entity Bean Via a Session Bean. Instead of calling getCustomerName(), getCustomerAddress(), getCustomerCity() methods separately will increase the network traffic, Instead you can call getCustomerDetails() which inturn will return CustomerVO object which contains all the customer data.

I agree. Here's the link:
subject: Singleton Pattern
It's not a secret anymore!