Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Singleton

Singleton

Scheduled Pinned Locked Moved C#
regexhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hatim_ali
    wrote on last edited by
    #1

    hi, I need a global store for storing error messages. It could be done using singleton. Now whats the difference between the following two. 1. Implement singleton pattern. 2. Creat a class. Make its contructor private. Expose the functionality using static functions. In singleton pattern a single object is created but in 2nd approach no object is created. Which approach is better ?? Thanks...

    B 1 Reply Last reply
    0
    • H hatim_ali

      hi, I need a global store for storing error messages. It could be done using singleton. Now whats the difference between the following two. 1. Implement singleton pattern. 2. Creat a class. Make its contructor private. Expose the functionality using static functions. In singleton pattern a single object is created but in 2nd approach no object is created. Which approach is better ?? Thanks...

      B Offline
      B Offline
      Brian Nottingham
      wrote on last edited by
      #2

      If there is no explicit need for an object instance, I find the use of all static members simpler. If you want to use it to persist data using the framework's builtin serialization, then you would need an object.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups