Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Suppose there is an Online shopping cart application having
different objects like Cart, SelectionItem, Billing,
COnfiguration, Authentication, Authorization,
PersonalDetails etc. Out of this which one can be made a
singleton pattern and why?

Answer Posted / sabir hussain

Singleton ensure that class has only one instance and
provide a global point of access to it.

It can be applied in a situation where your implementation
is independent and utilize resource that should be
initialized once within your application environment.

1) So Configuration can be singleton as we configure
resources that are globally used with your application. (ex:
database connection info.)

2) Authentication and Authorization component can also be
singleton as there implementation are independent and will
not solve any purpose if instantiated twice, if you look in
terms of spring framework all such components are singleton.
Both the component can independently authenticate or
authorize user or user info (validating credit card info).

Cart, SelectionItem and Billing are user specific generally
session scoped, and there can be more then one session per
application, so they cant be Singleton for obvious reason.

Is This Answer Correct ?    16 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you generate random numbers in java?

956


Is main an identifier?

945


Is empty set an element of empty set?

1030


what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent

2105


What is native method in java?

1014


Can java object be locked down for exclusive use by a given thread?

948


How a variable is stored in memory?

922


Can we have return statement in finally clause? What will happen?

913


What 5 doubled?

930


Explain the difference between jvm and jre?

974


What is an arraylist in java?

989


What is the use of default method in interface in java?

964


Detail discussions on JVM, memory management and garbage collector.

921


What is the function of log?

947


what is a thread pool in java and why is it used?

937