Singleton Patterns, where do I put it?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Sheppard

    Singleton Patterns, where do I put it?

    Hello,

    I am working on a 3teired project, data,bizlogic, userinterface.. .I have a
    global class that at current is being passed around as parameters, this is,
    to say the least messy...

    I am reading up about singletons, but I wonder where to place it? Should I
    stick it in with the userinterface.. ..how do I make it globally accessable
    if its in a different layer/project...

    Sorry if I sound like a noob, I am noob...
    Thank you
    John



  • Cowboy \(Gregory A. Beamer\)

    #2
    Re: Singleton Patterns, where do I put it?

    If the singleton is used for UI bits, then the UI project (web project,
    winforms project) is the correct place. The example here would be
    application settings for the UI.

    If not, then it does not belong there. It belongs in the layer where it is
    used. If it is database settings, you can guess where it goes. If neither DB
    nor UI, it is probably a business object. I say probably, as you may be
    using a facade pattern and have it there (not as likely).

    Short answer: Need to know more about what you are placing in the singleton
    to answer more concretely.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    *************** *************** *************** ****
    | Think outside the box!
    |
    *************** *************** *************** ****
    "John Sheppard" <spam@nospam.co mwrote in message
    news:fhtvkp0r2m @news2.newsguy. com...
    Hello,
    >
    I am working on a 3teired project, data,bizlogic, userinterface.. .I have a
    global class that at current is being passed around as parameters, this
    is, to say the least messy...
    >
    I am reading up about singletons, but I wonder where to place it? Should I
    stick it in with the userinterface.. ..how do I make it globally accessable
    if its in a different layer/project...
    >
    Sorry if I sound like a noob, I am noob...
    Thank you
    John
    >
    >
    >

    Comment

    • John Sheppard

      #3
      Re: Singleton Patterns, where do I put it?

      I answered my own question...it works good!

      I just put it in my Business Logic layer cause all lower layers use it...

      Thanks for anyone who read my message...


      "John Sheppard" <spam@nospam.co mwrote in message
      news:fhtvkp0r2m @news2.newsguy. com...
      Hello,
      >
      I am working on a 3teired project, data,bizlogic, userinterface.. .I have a
      global class that at current is being passed around as parameters, this
      is, to say the least messy...
      >
      I am reading up about singletons, but I wonder where to place it? Should I
      stick it in with the userinterface.. ..how do I make it globally accessable
      if its in a different layer/project...
      >
      Sorry if I sound like a noob, I am noob...
      Thank you
      John
      >
      >
      >

      Comment

      • John Sheppard

        #4
        Re: Singleton Patterns, where do I put it?

        Thanks Cowboy...

        Sorry my server was lagging at work and didnt see your response...

        Im still learning about patterns, at current the singleton is the first
        pattern im implementing...

        At current it is a Business object so its going there...I know we have some
        bad architecture issues which im working through, so its kinda half UI half
        BO...but it will in the end be a BO layer...

        Thanks once again, good answer, I very much appreciate it
        John

        "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamMwrote in
        message news:%231S3dV$K IHA.4272@TK2MSF TNGP06.phx.gbl. ..
        If the singleton is used for UI bits, then the UI project (web project,
        winforms project) is the correct place. The example here would be
        application settings for the UI.
        >
        If not, then it does not belong there. It belongs in the layer where it is
        used. If it is database settings, you can guess where it goes. If neither
        DB nor UI, it is probably a business object. I say probably, as you may be
        using a facade pattern and have it there (not as likely).
        >
        Short answer: Need to know more about what you are placing in the
        singleton to answer more concretely.
        >
        --
        Gregory A. Beamer
        MVP, MCP: +I, SE, SD, DBA
        >
        *************** *************** *************** ****
        | Think outside the box! |
        *************** *************** *************** ****
        "John Sheppard" <spam@nospam.co mwrote in message
        news:fhtvkp0r2m @news2.newsguy. com...
        >Hello,
        >>
        >I am working on a 3teired project, data,bizlogic, userinterface.. .I have
        >a global class that at current is being passed around as parameters, this
        >is, to say the least messy...
        >>
        >I am reading up about singletons, but I wonder where to place it? Should
        >I stick it in with the userinterface.. ..how do I make it globally
        >accessable if its in a different layer/project...
        >>
        >Sorry if I sound like a noob, I am noob...
        >Thank you
        >John
        >>
        >>
        >>
        >
        >

        Comment

        • Cowboy \(Gregory A. Beamer\)

          #5
          Re: Singleton Patterns, where do I put it?

          If you want a decent enough, and cheap enough, set of patterns in a "real
          world" application, consider looking at dofactory.com and purchasing the
          Pattern Framework. I disagree with parts of the implementation, but it is a
          great learning tool. It implements nearly every pattern, somewhere, and
          illustrates the use of a facade between business and UI, which is rather
          nice.

          My biggest issue is with the implementation of the data layer, as I feel it
          is a bit too complex for a maintainable solution, but it does work as a
          basic pattern.

          --
          Gregory A. Beamer
          MVP, MCP: +I, SE, SD, DBA

          *************** *************** *************** ****
          | Think outside the box!
          |
          *************** *************** *************** ****
          "John Sheppard" <nospam@spamspa m.comwrote in message
          news:fi0nj6023f q@news4.newsguy .com...
          Thanks Cowboy...
          >
          Sorry my server was lagging at work and didnt see your response...
          >
          Im still learning about patterns, at current the singleton is the first
          pattern im implementing...
          >
          At current it is a Business object so its going there...I know we have
          some bad architecture issues which im working through, so its kinda half
          UI half BO...but it will in the end be a BO layer...
          >
          Thanks once again, good answer, I very much appreciate it
          John
          >
          "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamMwrote in
          message news:%231S3dV$K IHA.4272@TK2MSF TNGP06.phx.gbl. ..
          >If the singleton is used for UI bits, then the UI project (web project,
          >winforms project) is the correct place. The example here would be
          >application settings for the UI.
          >>
          >If not, then it does not belong there. It belongs in the layer where it
          >is used. If it is database settings, you can guess where it goes. If
          >neither DB nor UI, it is probably a business object. I say probably, as
          >you may be using a facade pattern and have it there (not as likely).
          >>
          >Short answer: Need to know more about what you are placing in the
          >singleton to answer more concretely.
          >>
          >--
          >Gregory A. Beamer
          >MVP, MCP: +I, SE, SD, DBA
          >>
          >************** *************** *************** *****
          >| Think outside the box! |
          >************** *************** *************** *****
          >"John Sheppard" <spam@nospam.co mwrote in message
          >news:fhtvkp0r2 m@news2.newsguy .com...
          >>Hello,
          >>>
          >>I am working on a 3teired project, data,bizlogic, userinterface.. .I have
          >>a global class that at current is being passed around as parameters,
          >>this is, to say the least messy...
          >>>
          >>I am reading up about singletons, but I wonder where to place it? Should
          >>I stick it in with the userinterface.. ..how do I make it globally
          >>accessable if its in a different layer/project...
          >>>
          >>Sorry if I sound like a noob, I am noob...
          >>Thank you
          >>John
          >>>
          >>>
          >>>
          >>
          >>
          >

          Comment

          Working...