File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes Constant Data Manager pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Constant Data Manager pattern " Watch "Constant Data Manager pattern " New topic
Author

Constant Data Manager pattern

Mihai Lihatchi
Ranch Hand

Joined: Oct 28, 2005
Posts: 138

Hello.
Just wanted to know whether this pattern has some major drawbacks in large J2EE applications.
Currently I am looking at reading all the constant data from either a properties file or the database.
For now the constant data is stored in static fields in all the classes from my application.
The only drawback is that I have to keep using the ConstantDataManager everywhere in the application and that the static fields do not make as much sense as when stored in the corresponding classes .

Do you have experience with implementing this pattern ? It looks to me as I have a good solution with this pattern.
PS: I am working with Spring & Hibernate if this helps.


Mihai


Better, faster, lighter Java ... you mean Ruby right ?
SCEA5,SCBCD1.3,SCWCD5,SCJP1.4 - memories from my youth.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
What problem are you trying to solve by using property files or a database?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Mihai Lihatchi
Ranch Hand

Joined: Oct 28, 2005
Posts: 138

It is a matter of data that changes every 2 -3 years and can't be hardcoded in the application and yet it is described a lot of classes from the domain (public static and final).
Mihai Lihatchi
Ranch Hand

Joined: Oct 28, 2005
Posts: 138

It looks like it is a bad idea after all.

Thanks for your help Ilja.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
What is a bad idea, and why? And how did I help?
Mihai Lihatchi
Ranch Hand

Joined: Oct 28, 2005
Posts: 138

by making me think..
It is a bad idea because having the static data in one place may save modifications but it does not make sense anymore for other classes developers from the team .


Mihai
[ November 15, 2006: Message edited by: Mihai Lihatchi ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Mihai Lihatchi:
by making me think..





It is a bad idea because having the static data in one place may save modifications but it does not make sense anymore for other classes developers from the team .


Well, but having to change the code everytime a value changes is a bad idea, too, especially when we know that it *will* change at regular intervals - isn't it?

Is there a solution that would solve both problems?
Mihai Lihatchi
Ranch Hand

Joined: Oct 28, 2005
Posts: 138

Don't know. However at this point can't afford to take these chances .. I am not allowed to take such a decision.
A compromise sounds as the best solution. (that is develop repositories for constant data per modules/sections of the application).
Anyhow for now just canceled any changes due to risks involved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Constant Data Manager pattern