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. Other Discussions
  3. Clever Code
  4. Another fun one

Another fun one

Scheduled Pinned Locked Moved Clever Code
databasedebuggingsaleshelp
3 Posts 3 Posters 12 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.
  • R Offline
    R Offline
    Rama Krishna Vavilala
    wrote on last edited by
    #1

    When it comes to Multi-Threading it is always wise to be safer.

    template<typename T>
    class ItemTypeInfo
    {
    public:
    //Get ItemTableName is callable from multiple threads
    std::string GetItemTableName()
    {
    static std::string _strTypeName = GetStringFromRegistry();
    return _strTypeName;
    }
    };

    Customer's complaint was that the application gave an error: "Database Table name is not valid". I struggled days to find this one out.


    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -Brian Kernighan

    S 1 Reply Last reply
    0
    • R Rama Krishna Vavilala

      When it comes to Multi-Threading it is always wise to be safer.

      template<typename T>
      class ItemTypeInfo
      {
      public:
      //Get ItemTableName is callable from multiple threads
      std::string GetItemTableName()
      {
      static std::string _strTypeName = GetStringFromRegistry();
      return _strTypeName;
      }
      };

      Customer's complaint was that the application gave an error: "Database Table name is not valid". I struggled days to find this one out.


      Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -Brian Kernighan

      S Offline
      S Offline
      Shog9 0
      wrote on last edited by
      #2

      Rama Krishna Vavilala wrote:

      static std::string

      :doh: But why?!

      ---- Scripts i’ve known... CPhog 1.8.2 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.2 - printer-friendly forums Expand all 1.0 - Expand all messages In-place Delete 1.0 - AJAX-style post delete Syntax 0.1 - Syntax highlighting for code blocks in the forums

      R 1 Reply Last reply
      0
      • S Shog9 0

        Rama Krishna Vavilala wrote:

        static std::string

        :doh: But why?!

        ---- Scripts i’ve known... CPhog 1.8.2 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.2 - printer-friendly forums Expand all 1.0 - Expand all messages In-place Delete 1.0 - AJAX-style post delete Syntax 0.1 - Syntax highlighting for code blocks in the forums

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        Shog9 wrote:

        But why?!

        Because :)

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        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