sunil g nair

+ Follow
since Jun 03, 2002
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sunil g nair

Q. Iterative development is used for
a) Saving initial development time
b) Reducing complexity
c) For saving time
d) For Learning
which are the correct answers.
I will say only B is right.
a is not because iterative development has its own overheads, they only pay off in the long run
c saving time is true but not the primary motive of iterative development and then it may not be true for less complex systems.
A tuely exhaustive list
Let the next stone be thrown by a person who is not a jerk in some way.
18 years ago
is that what u call it.....cst
and u r right the cancer is above and over the cst scare.
And right about anything can cause cancer....from last the old saying too much of anything is bad....even good old water can drown you.
18 years ago
None can beat George Bush.
Every time I see his face i burst out laughing. His face never seems to change from sept 11....comeon guys it is a war....but we have a life to live
18 years ago
Sounds intresting although it will freak me out on the cancer threat.
I think corporal tunnel syndrome is more manageable
18 years ago
Dear Michael Ernest it looks like you are blissfully ignorant about outsourcing.
To begin with these companies are no ply by night shops....most of them have CMM level 4 or higher.
Most of the fortune 10 companies outsource their work...both software development and call center.
It is not just that most product development also happens a major part involved in a new release of Oracle happens offsore.
How they do it is because of cheap labor...not really cheap they pay their employees heavily...but the pay in the local currency which equates to a lot less no. of dollars.
Talking of talents....california (silicon valley) is full of immigrants.....these people have a huge part in making software get the same people in their native country minus the US Visas. They work twise as hard though since they are yet to reach their goals.
I work for a top 5 cunsulting firm and now they are outsourcing a majority of their work to their center in Bombay....and I think it makes sense
18 years ago
public static void Locale.setDefault( Locale newDefault) will surely disqualify it as being a singleton if this method overides the instance variable.
Like I said singleton by itself is of no great many of the other combine it with others and suddenly you see it can be quite a blessing and all its cited limitations is when you apply the pattern in places where it was not supposed to be.
To make things clear singleton never says that there will be just one instance there could be multiple depending on the load.
Secondly I am not a fan of singleton either all I was saying was to have either a singleton or a factory (if stuff differs) or a pool (of similar stuff) and abstract the creation logic by using a proxy.
I do not like singleton but it should still be very much applicable to the situation that you mentioned.
1. I always keep my application configuration in a file and have the singleton instance populated from the file when the application starts.
2. Regarding two different applications I will always have two different configurations or one base configuration and two application specific configuration and have a singleton object for each configuration.
3. Since my configuration is loaded from a file it is just a matter of changing the file for reuse.
This is how most app-servers used to initialize their environments in the start up class.
(If there is no startup class you could do it in your Servlet init)
Like somebody said singleton is a good pattern for providing information which is static (like application configuration etc).
Depending on the requirement you could do with lazy initalization. If the clients are numerous and the no of hits are of a mamoth proportion then use pooling. Pooling is very scalable.
And it will be good to abstract this design decesion based on a proxy.
The proxy encapsulates the logic involved in returning the instance and all that the client does is call the getInstance() on the proxy.
This is a copy of the patter I sumbitted on This is a really nice store house for enterprise design patterns.

This pattern is a combination of three established patterns.
1. Data transfer object factory
2. Command pattern
3. Data access objects (using abstract factory)
The Data transfer object factory (Implemented as a Session EJB) is the interface to the business client. The only alteration being that the Data transfer object factory does not create any data transfer object as such. The Data transfer object factory in turn uses a command pattern to invoke the specific command that will handle the DTO creation.
The DTO Specific command will have all the entity relationship info needed to create the DTO. It will then invoke the Data access objects abstract factory to get the appropriate factory and then it will call that factory to get the DAO from which it gets the entity values.
The Data access objects (using abstract factory) strategy will ensure that your data source can be anything. It could also be a good way to abstract the business logic from persistence technologies like ORM, EJB (Entity) or Data Objects.
Further clarifications:
DTO Factory is required to be a stateless session bean only if the clients are non-EJB.
You are right it does use the container features of the app server for non-EJB clients.
The DTO Factory is different from the session fa�ade since the fa�ade is just a fa�ade to your persistence framework (entity EJB) and it typically includes business logic. Whereas the DTO Factory in my case is just a routing controller, which uses command pattern to route to, the appropriate command which will handle the DTO creation. (You got this right too)
The Business logic to create the DTO is typically embedded in the command. So the DTO Factory is not cluttered and the commands are free to inherit from a command specific base class other than the DTO Factory.
Ideally speaking the DTO Factory should be called a command controller rather than a factory. But the client side interface to the business clients will be very similar to a DTO Factory. I used the DTO factory term because of this similarity in objectives and thus make it easier for people who are already familiar to DTO Factory pattern.
use a multipart message ,
here is some sample code.

public static void main(String[] args) {
try {
if (args.length != 7) {
System.out.println("usage: java sendfile <to> <from> <subject> <text> <smtp host> <file> true|false");
String to = args[0];
if ((to == null) || (to.trim().equals("")))
throw new Exception("To Address is balnk");
String from = args[1];
if ((from == null) || (from.trim().equals("")))
throw new Exception("From Address is balnk");
String msgText1 = args[2];
String subject = args[3];
String host = args[4];
if ((host == null) || (host.trim().equals("")))
throw new Exception("Host Address is balnk");
String filename = args[5];
boolean debug = Boolean.valueOf(args[6]).booleanValue();
// create some properties and get the default Session
Properties props = System.getProperties();
props.put("", host);
Session session = Session.getDefaultInstance(props, null);
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = { new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
// create and fill the first message part
MimeBodyPart mbp1 = new MimeBodyPart();
// create the second message part
MimeBodyPart mbp2 = new MimeBodyPart();
if ((filename == null) || (filename.trim().equals(""))) {
// attach the file to the message
FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
// create the Multipart and its parts to it
Multipart mp = new MimeMultipart();
if ((filename == null) || (filename.trim().equals("")))
// add the Multipart to the message
// set the Date: header
msg.setSentDate(new Date());
// send the message
} catch (MessagingException mex) {
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
} catch (Exception e) {
this is a modiifcation of the sample code within the mail api.
Hope this helps
Sunil Nair
19 years ago
Please let me know if you got a response on this. We are facing a similar issue.
Any help will be appriciated.
Sunil Nair
19 years ago
J2EE design patterns will be good, and it is from guys out at sun....but it is very Java specific...rather J2EE specific.
The gang of four have their own book which many term as the bible of patterns.
There are a number of ways of doing things many of which are wrong and many of which have varying levels of correctness.
As to why we use a controller, well, that depends a lot on what the controller does.
Like for example a simple example will be if the controller makes use of a command pattern.
In this scenario the controller may be smart Servlet which gets the user action, looks up the corresponding Command for that action from a property file, instantiate and execute that command, which in turn may call a series of sub-commands (re-usable).
The command will then let the smart-Servlet know which page to direct the request to.
The struts framework is an advanced framework designed on this basic principle.
I may not have done a good job of explaining what I have in mind, but the design pattern link within Java soft should be helpful.