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

static references

 
Tony Bouer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to hear your ideas about use of static references in standalone/client-server applications as the case of our asignment. As I'm a J2EE programmer the calls have ussually the scope of a request. In case of the assignment if you think you should use a layer separation approach how to make the class avaible allways with the same state ? Currently, I have a static reference from my controller to my business layer and I have a singleton at data class. What do you think about this issue ? Is this an issue ? I'm used to avoid the use of static atributes in applications I develop.

Thanks,
Tony
 
Adam Nace
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about everybody else, but your question kind of confused me. Could you try to restate it in another way?

I'll make a small attempt to answer, however. I would avoid making things static or singletons because it's not necessary. In the case of the assignment, you have another way to identify the database: You will most likely create a single instance of a server object (I use the term loosely to define which over object is responsible for creating the server socket for clients to connect to). This server object can have the DAO as an instance variable. You could just as easily create multiple instances of the server object, but that would make no sense. You have a single server, so just give it the DAO as an instance variable. No static or singletonness necessary.

That would be my recommendation.

- Adam
 
Tony Bouer
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand what you are saying and I think that it's easy to do. However, I have a layered application MVC -- > Facade --> Data Access files and in case I want implement your suggestion I need to initialize a big number of layer responsible classes with its instance variables. I don't like it so much but I'm going to try to check this approach and see what happens.

BTW, thanks !

Tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic