Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2 databases?

 
Mike Wang
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a question about the instance of databases:
for example, If I have two db files,
Data d1=new Data(file1);
Data d2=new Data(file2);
so, there should be no static member inside the Data class, right?
for example the lock?
A solution is to use multiton design pattern with the file name as the key.
please comment on my design.
thanks
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so, there should be no static member inside the Data class, right?
Well, you might have some static members. E.g. you might have a static HashMap which is part of your multiton design. And of course there may be static constants. But in general most data should not be in static variables, correct.
for example the lock?
A solution is to use multiton design pattern with the file name as the key.
please comment on my design.

Sounds good. This isn't a requirement for the assignment, so don't let this multiton idea get complex; you're not really going to use it much. But it's not a bad idea.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic