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. The Weird and The Wonderful
  4. Wow

Wow

Scheduled Pinned Locked Moved The Weird and The Wonderful
ruby
6 Posts 4 Posters 5 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.
  • E Offline
    E Offline
    eggsovereasy
    wrote on last edited by
    #1

    Every once and a while I find a little gem in my own code. I encountered this one today:

    if (new Project(pid).HasSubstatus)
    useSubStatus = true;
    else
    useSubStatus = false;

    if (useSubStatus)
    ...

    D L 2 Replies Last reply
    0
    • E eggsovereasy

      Every once and a while I find a little gem in my own code. I encountered this one today:

      if (new Project(pid).HasSubstatus)
      useSubStatus = true;
      else
      useSubStatus = false;

      if (useSubStatus)
      ...

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

      Don't we all... I've today found (my code) that was something like:

      set
      {
      if(value!=null)
      {
      DoSomething();
      Trace.Write(value.ToString());
      }
      else
      {
      Trace.Write(value.ToString());
      }
      }

      :doh: Apart from ugly way to set boolean variable,

      eggsovereasy wrote:

      new Project(pid).HasSubstatus

      this just screams "static method"*. :) *assuming the language supports it and there aren't any hidden side effects in Project constructor


      [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

      E J 2 Replies Last reply
      0
      • D DavidNohejl

        Don't we all... I've today found (my code) that was something like:

        set
        {
        if(value!=null)
        {
        DoSomething();
        Trace.Write(value.ToString());
        }
        else
        {
        Trace.Write(value.ToString());
        }
        }

        :doh: Apart from ugly way to set boolean variable,

        eggsovereasy wrote:

        new Project(pid).HasSubstatus

        this just screams "static method"*. :) *assuming the language supports it and there aren't any hidden side effects in Project constructor


        [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

        E Offline
        E Offline
        eggsovereasy
        wrote on last edited by
        #3

        Yep, the double wammy!

        1 Reply Last reply
        0
        • D DavidNohejl

          Don't we all... I've today found (my code) that was something like:

          set
          {
          if(value!=null)
          {
          DoSomething();
          Trace.Write(value.ToString());
          }
          else
          {
          Trace.Write(value.ToString());
          }
          }

          :doh: Apart from ugly way to set boolean variable,

          eggsovereasy wrote:

          new Project(pid).HasSubstatus

          this just screams "static method"*. :) *assuming the language supports it and there aren't any hidden side effects in Project constructor


          [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

          J Offline
          J Offline
          J a a n s
          wrote on last edited by
          #4

          dnh wrote:

          eggsovereasy wrote: new Project(pid).HasSubstatus this just screams "static method"

          It is not a static method. ;)

          *jaans

          E 1 Reply Last reply
          0
          • J J a a n s

            dnh wrote:

            eggsovereasy wrote: new Project(pid).HasSubstatus this just screams "static method"

            It is not a static method. ;)

            *jaans

            E Offline
            E Offline
            eggsovereasy
            wrote on last edited by
            #5

            But it should be, so I can do: Project.HasSubStatus(projectId);

            1 Reply Last reply
            0
            • E eggsovereasy

              Every once and a while I find a little gem in my own code. I encountered this one today:

              if (new Project(pid).HasSubstatus)
              useSubStatus = true;
              else
              useSubStatus = false;

              if (useSubStatus)
              ...

              L Offline
              L Offline
              Lutoslaw
              wrote on last edited by
              #6

              Maybe to determine whether "HasSubstatus" full loading of an object is required AND the object itself is not used anymore AND the useSubStatus is used later. Anyway, nothing justifies writing

              if (new Project(pid).HasSubstatus)
              useSubStatus = true;
              else
              useSubStatus = false;

              instead of

              useSubStatus = new Project(pid).HasSubstatus;

              :-)

              Greetings - Gajatko

              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