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. IT & Infrastructure
  4. 0xDEF

0xDEF

Scheduled Pinned Locked Moved IT & Infrastructure
csharpvisual-studiocomgraphicsperformance
9 Posts 5 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.
  • D Offline
    D Offline
    DavidNohejl
    wrote on last edited by
    #1

    Anyone using 0xDEF as default value for int? (when you don't really care what value it is, e.g in test for some default value setter)


    [My Blog]
    "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
    "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

    P realJSOPR 2 Replies Last reply
    0
    • D DavidNohejl

      Anyone using 0xDEF as default value for int? (when you don't really care what value it is, e.g in test for some default value setter)


      [My Blog]
      "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
      "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      dnh wrote:

      Anyone using 0xDEF as default value for int?

      Nope. Go wild.

      Deja View - the feeling that you've seen this post before.

      M 1 Reply Last reply
      0
      • D DavidNohejl

        Anyone using 0xDEF as default value for int? (when you don't really care what value it is, e.g in test for some default value setter)


        [My Blog]
        "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
        "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        That's um... stupid (unless 3567 somehow indicates something special as a default value to your program). If you're just trying to be clever with hex values, you're not going to accomplish anything more than pissing off real programmers that will be tasked with maintaining your freakish attempts at coding.

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        D 1 Reply Last reply
        0
        • realJSOPR realJSOP

          That's um... stupid (unless 3567 somehow indicates something special as a default value to your program). If you're just trying to be clever with hex values, you're not going to accomplish anything more than pissing off real programmers that will be tasked with maintaining your freakish attempts at coding.

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          D Offline
          D Offline
          DavidNohejl
          wrote on last edited by
          #4

          Thanks. The scenario where I was thinking about this is following: Say I have method void GetSomethingFromConfig(ref int result); When writing unit test for this method, I want to make sure that for input that cannot be parsed the output value of result stay the same as its input value (which is some default value, it's value is irrelevant now). I don't want to use 0, because that happen to be default value of int, so the probability that bug in GetSomethingFromConfig will "reset" output value to 0 is way higher then to 3576. So what number to choose, 42,123,...? I guess I could slam the numeric part of keyboad and add comment saying "this is random default value for test purposes", but it looks like overkill to me. Without the comment, maintainance programmer can wonder why 42, why 123 etc. Yes I am trying to be clever with hex in this case; 0xDEF(ault) value by convention. Yes, it is somewhat cryptic. If I didn't realise it is I wouldn't post here :) I want to point out that I am not using this value in production code, (certailny not because it's looking cool) but I think about using it in tests.


          [My Blog]
          "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
          "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

          T 1 Reply Last reply
          0
          • D DavidNohejl

            Thanks. The scenario where I was thinking about this is following: Say I have method void GetSomethingFromConfig(ref int result); When writing unit test for this method, I want to make sure that for input that cannot be parsed the output value of result stay the same as its input value (which is some default value, it's value is irrelevant now). I don't want to use 0, because that happen to be default value of int, so the probability that bug in GetSomethingFromConfig will "reset" output value to 0 is way higher then to 3576. So what number to choose, 42,123,...? I guess I could slam the numeric part of keyboad and add comment saying "this is random default value for test purposes", but it looks like overkill to me. Without the comment, maintainance programmer can wonder why 42, why 123 etc. Yes I am trying to be clever with hex in this case; 0xDEF(ault) value by convention. Yes, it is somewhat cryptic. If I didn't realise it is I wouldn't post here :) I want to point out that I am not using this value in production code, (certailny not because it's looking cool) but I think about using it in tests.


            [My Blog]
            "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
            "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

            T Offline
            T Offline
            TJoe
            wrote on last edited by
            #5

            If you cannot parse the config file, then you should probably throw an exception in your method. I don't think using a special return value in debug only code for unit tests is the correct way to do it. Mainly because your Debug and Release code now have different behavior when the config value cannot be parsed. But also because it's not a standard practice.

            Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

            D 1 Reply Last reply
            0
            • T TJoe

              If you cannot parse the config file, then you should probably throw an exception in your method. I don't think using a special return value in debug only code for unit tests is the correct way to do it. Mainly because your Debug and Release code now have different behavior when the config value cannot be parsed. But also because it's not a standard practice.

              Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

              D Offline
              D Offline
              DavidNohejl
              wrote on last edited by
              #6

              TJoe wrote:

              If you cannot parse the config file, then you should probably throw an exception in your method.

              I'd agree if it was incorrect data. It's missing data. For configuration file, if you can have sensible defaults, why would you require user of your config to put ALL attributes there? Btw there indeed is method that checks for attributes that MUST be set, that throws config. exception. More later... got to go.


              [My Blog]
              "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
              "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

              T 1 Reply Last reply
              0
              • D DavidNohejl

                TJoe wrote:

                If you cannot parse the config file, then you should probably throw an exception in your method.

                I'd agree if it was incorrect data. It's missing data. For configuration file, if you can have sensible defaults, why would you require user of your config to put ALL attributes there? Btw there indeed is method that checks for attributes that MUST be set, that throws config. exception. More later... got to go.


                [My Blog]
                "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
                "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

                T Offline
                T Offline
                TJoe
                wrote on last edited by
                #7

                If you are using 0xDEF as the default value in your unit test, then it's fine. So you pass in 0xDEF into your Get method and expect 0xDEF back out (for missing config entries). Originally, it sound to me like the Get method was going to return 0xDEF for a default if the config entry was missing and it was a debug build.

                Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

                D 1 Reply Last reply
                0
                • T TJoe

                  If you are using 0xDEF as the default value in your unit test, then it's fine. So you pass in 0xDEF into your Get method and expect 0xDEF back out (for missing config entries). Originally, it sound to me like the Get method was going to return 0xDEF for a default if the config entry was missing and it was a debug build.

                  Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

                  D Offline
                  D Offline
                  DavidNohejl
                  wrote on last edited by
                  #8

                  TJoe wrote:

                  So you pass in 0xDEF into your Get method and expect 0xDEF back out (for missing config entries).

                  Yep! Ow wow, I am going to read again what I originally wrote :-O


                  [My Blog]
                  "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn
                  "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

                  1 Reply Last reply
                  0
                  • P Pete OHanlon

                    dnh wrote:

                    Anyone using 0xDEF as default value for int?

                    Nope. Go wild.

                    Deja View - the feeling that you've seen this post before.

                    M Offline
                    M Offline
                    Mark Churchill
                    wrote on last edited by
                    #9

                    I strongly feel this thread deserves an award of some kind.

                    Mark Churchill Director Dunn & Churchill

                    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