Use Singleton or Static Class in this example?

H

howachen

Consider the following example:

E.g.

Use a class to load configuration data from database at application
startup, anywhere in the application should be able to access the
configuration information as they are needed.

This example is a classic example of using static class or singleton
plattern, isn't?

Which one you prefer ? Singleton or Static ?

Thanks...
 
D

Danno

Consider the following example:

E.g.

Use a class to load configuration data from database at application
startup, anywhere in the application should be able to access the
configuration information as they are needed.

This example is a classic example of using static class or singleton
plattern, isn't?

Which one you prefer ? Singleton or Static ?

Thanks...

For something like that I would need to look at what is being built
around it... Is it a desktop app, a web app, a service? What is the
purpose of the app? What existing technologies does it depend on, etc.
 
H

howachen

Danno 寫é“:
For something like that I would need to look at what is being built
around it... Is it a desktop app, a web app, a service? What is the
purpose of the app? What existing technologies does it depend on, etc.

will you have different choice if they are built on different platform?
such as web or desktop? why?
 
D

Danno

Danno 寫é“:


will you have different choice if they are built on different platform?
such as web or desktop? why?

Well for example, when creating a web app, loading configuration can
come during servlet context setup using a context listener and from
there I would bind those values to an application context. I have to
say that that is not the only way. In a desktop app, I would probably
have to do some sort of distributed programming solution or just call
the database directly. If its also a desktop solution I would like to
know if the configuration files are like a map (key, value) structure,
or they are complex relational objects.

Lots to consider.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top