Forum Post: RE: Singleton vs Static

  • Thread starter Thread starter Peter Judge
  • Start date Start date
Status
Not open for further replies.
P

Peter Judge

Guest
As Thomas Mercer-Hursh says early in the thread Singleton is a pattern; static is a language feature. You can easily have singletons that are not implemented using static members. The only trick is that someone, somewhere needs to hold at least one reference otherwise the garbage collector will do its work. If you want to have 2 instances of the same class running on client and server, you will need to pass the values back and forth. Were you thinking of passing the singleton itself? -- peter From: Marko Myllymäki [mailto:bounce-mmy@community.progress.com] Sent: Monday, 08 December, 2014 06:39 To: TU.OE.Development@community.progress.com Subject: RE: [Technical Users - OE Development] Singleton vs Static RE: Singleton vs Static Reply by Marko Myllymäki I found this old thread after reading Tom Bascom's presentation slides about static classes: http://pugchallenge.eu/images/2014pdfs/tom_bascom_stop_shared_variables.pptx We have been using the same approach for replacing shared variables with static properties. However, now I started to wonder if we should use a singleton class instead. In OE 11.4 you can pass an object as a parameter between client and AppServer. Using singleton, we could send this singleton object to AppServer but the same can not be done with a static class. So, if we need to access the same common values both in AppServer and client, using a singleton pattern might be useful. Any thoughts? Stop receiving emails on this subject. Flag this post as spam/abuse.

Continue reading...
 
Status
Not open for further replies.
Back
Top