• 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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!