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. What goes around, comes around...

What goes around, comes around...

Scheduled Pinned Locked Moved The Weird and The Wonderful
6 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
    Duncan Edwards Jones
    wrote on last edited by
    #1

    for (Int16 i = 1; i <= 2; i++)

    I suppose this is the DRY principle taken to its logical conclusion

    Sander RosselS M P P 4 Replies Last reply
    0
    • D Duncan Edwards Jones

      for (Int16 i = 1; i <= 2; i++)

      I suppose this is the DRY principle taken to its logical conclusion

      Sander RosselS Offline
      Sander RosselS Offline
      Sander Rossel
      wrote on last edited by
      #2

      My first thought was "that will execute three times" and then I noticed it starts at 1 :doh: VS2015 would also give the advice to "simplify" Int16 to short (as Int16 is waaaay to esoteric for us simpletons) :D

      Read my (free) ebook Object-Oriented Programming in C# Succinctly. Visit my blog at Sander's bits - Writing the code you need. Or read my articles here on CodeProject.

      Simplicity is prerequisite for reliability. — Edsger W. Dijkstra

      Regards, Sander

      1 Reply Last reply
      0
      • D Duncan Edwards Jones

        for (Int16 i = 1; i <= 2; i++)

        I suppose this is the DRY principle taken to its logical conclusion

        M Offline
        M Offline
        Midi_Mick
        wrote on last edited by
        #3

        I could just imagine the next few lines being

        if (i == 1) {
        }
        else {
        }

        (Maybe too much time looking in QA)

        Cheers, Mick ------------------------------------------------ It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

        D 1 Reply Last reply
        0
        • M Midi_Mick

          I could just imagine the next few lines being

          if (i == 1) {
          }
          else {
          }

          (Maybe too much time looking in QA)

          Cheers, Mick ------------------------------------------------ It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

          D Offline
          D Offline
          Duncan Edwards Jones
          wrote on last edited by
          #4

          Fortunately not - though it does have an inner loop that is a foreach and I think it could be refactored away. Got to put some tight unit tests down around it first as there is little or no intent in evidence from code or comment.

          1 Reply Last reply
          0
          • D Duncan Edwards Jones

            for (Int16 i = 1; i <= 2; i++)

            I suppose this is the DRY principle taken to its logical conclusion

            P Offline
            P Offline
            Power Puff Boy
            wrote on last edited by
            #5

            Looks like that'll run fast and stable.

            Kitty at my foot and I waAAAant to touch it...

            1 Reply Last reply
            0
            • D Duncan Edwards Jones

              for (Int16 i = 1; i <= 2; i++)

              I suppose this is the DRY principle taken to its logical conclusion

              P Online
              P Online
              PIEBALDconsult
              wrote on last edited by
              #6

              Never heard of IF-less programming?

              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