What is the difference between all-static-methods and applying a singleton pattern?
Posted
by
shahensha
on Programmers
See other posts from Programmers
or by shahensha
Published on 2011-01-07T08:44:39Z
Indexed on
2012/03/23
11:38 UTC
Read the original article
Hit count: 228
I am making a database to store information about the users of my website (I am using stuts2 and hence Java EE technology). For the database I'll be making a DBManager. Should I apply singleton pattern here or rather make all it's methods static?
I will be using this DBManager for basic things like adding, deleting and updating User profiles. Along with it, I'll use for all other querying purposes, for instance to find out whether a username already exists and to get all users for administrative purposes and stuff like that.
My questions
- What is the benefit of singleton pattern?
- Which thing is most apt here? All static methods or a singleton pattern?
- Please compare both of them.
P.S. The database is bigger than this. Here I am talking only about the tables which I'll be using for storing User Information.
© Programmers or respective owner