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. Oww...

Oww...

Scheduled Pinned Locked Moved Clever Code
learning
6 Posts 4 Posters 3 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.
  • L Offline
    L Offline
    Luca Leonardo Scorcia
    wrote on last edited by
    #1

    This one bit me this morning... half an hour wasted:

    string stepType = ...;
    if (stepType != typeof(Link).GetType().FullName)
    {
    ....
    }

    It was, of course, the unnecessary GetType() call. Shame on me! ;)

    Luca The Price of Freedom is Eternal Vigilance. -- Wing Commander IV En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur. (But the best thing God has created, is a New Day.) -- Sigur Ròs - Viðrar vel til loftárása

    L B 2 Replies Last reply
    0
    • L Luca Leonardo Scorcia

      This one bit me this morning... half an hour wasted:

      string stepType = ...;
      if (stepType != typeof(Link).GetType().FullName)
      {
      ....
      }

      It was, of course, the unnecessary GetType() call. Shame on me! ;)

      Luca The Price of Freedom is Eternal Vigilance. -- Wing Commander IV En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur. (But the best thing God has created, is a New Day.) -- Sigur Ròs - Viðrar vel til loftárása

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      what happens when you change the name of the class? Either way, it's flawed ;P The better solution (IMO) would be:

      Type stepType = ...;
      if (stepType != typeof(Link))
      {
      ...
      }

      (it will be faster too!)

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 alpha 3 out now

      M L 2 Replies Last reply
      0
      • L leppie

        what happens when you change the name of the class? Either way, it's flawed ;P The better solution (IMO) would be:

        Type stepType = ...;
        if (stepType != typeof(Link))
        {
        ...
        }

        (it will be faster too!)

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 alpha 3 out now

        M Offline
        M Offline
        Mladen Jankovic
        wrote on last edited by
        #3

        leppie wrote:

        what happens when you change the name of the class?

        It'll take him another half an hour ;P

        Mostly, when you see programmers, they aren't doing anything. One of the attractive things about programmers is that you cannot tell whether or not they are working simply by looking at them. Very often they're sitting there seemingly drinking coffee and gossiping, or just staring into space. What the programmer is trying to do is get a handle on all the individual and unrelated ideas that are scampering around in his head. (Charles M Strauss)

        1 Reply Last reply
        0
        • L leppie

          what happens when you change the name of the class? Either way, it's flawed ;P The better solution (IMO) would be:

          Type stepType = ...;
          if (stepType != typeof(Link))
          {
          ...
          }

          (it will be faster too!)

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 alpha 3 out now

          L Offline
          L Offline
          Luca Leonardo Scorcia
          wrote on last edited by
          #4

          Well, it's part of a snippet that handled deserialization from XML of certain objects, stepType is an attribute value. If I had the live Type in memory, I'd have probably used if (stepType is Link). However it finally got refactored away with a proper object hierarchy :)

          Luca The Price of Freedom is Eternal Vigilance. -- Wing Commander IV En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur. (But the best thing God has created, is a New Day.) -- Sigur Ròs - Viðrar vel til loftárása

          L 1 Reply Last reply
          0
          • L Luca Leonardo Scorcia

            Well, it's part of a snippet that handled deserialization from XML of certain objects, stepType is an attribute value. If I had the live Type in memory, I'd have probably used if (stepType is Link). However it finally got refactored away with a proper object hierarchy :)

            Luca The Price of Freedom is Eternal Vigilance. -- Wing Commander IV En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur. (But the best thing God has created, is a New Day.) -- Sigur Ròs - Viðrar vel til loftárása

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            Luca Leonardo Scorcia wrote:

            Well, it's part of a snippet that handled deserialization from XML of certain objects, stepType is an attribute value.

            Ah, ok :)

            xacc.ide - now with TabsToSpaces support
            IronScheme - 1.0 alpha 3 out now

            1 Reply Last reply
            0
            • L Luca Leonardo Scorcia

              This one bit me this morning... half an hour wasted:

              string stepType = ...;
              if (stepType != typeof(Link).GetType().FullName)
              {
              ....
              }

              It was, of course, the unnecessary GetType() call. Shame on me! ;)

              Luca The Price of Freedom is Eternal Vigilance. -- Wing Commander IV En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur. (But the best thing God has created, is a New Day.) -- Sigur Ròs - Viðrar vel til loftárása

              B Offline
              B Offline
              BillWoodruff
              wrote on last edited by
              #6

              "En Það Besta Sem Guð Hefur Skapað, Er Nýr Dagur. (But the best thing God has created, is a New Day.) -- Sigur Ròs - Viðrar vel til loftárása" Hi Luca, That fascinating quote compelled me to go a-google; I assumed it was a quote from some medieval Scandinavian skald sitting on a hill watching a battle (or a nice plundering raid on an English town) commence and making notes for his edda or saga :) Even more fascinating that it's a quote from a contemporary Icelandic ambient music group, and that song title translates as "A Good Day for Airstrikes." thanks, Bill

              "The greater the social and cultural distances between people, the more magical the light that can spring from their contact." Milan Kundera in Testaments Trahis

              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