• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

static references

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic