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. General Programming
  3. C / C++ / MFC
  4. Does this line of code bother anyone?

Does this line of code bother anyone?

Scheduled Pinned Locked Moved C / C++ / MFC
databasedebuggingcollaborationquestiondiscussion
10 Posts 6 Posters 1 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.
  • S Offline
    S Offline
    stgagnon
    wrote on last edited by
    #1

    A whipper-snapper (sort-of) on my team wrote this:

    for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
    

    I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.

    _ L CPalliniC C 4 Replies Last reply
    0
    • S stgagnon

      A whipper-snapper (sort-of) on my team wrote this:

      for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
      

      I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Here's my take on this. If you need a minute to think about what a code statement does, then it has to go. Get rid of it.

      «_Superman_»  _I love work. It gives me something to do between weekends.

      _Microsoft MVP (Visual C++) (October 2009 - September 2013)

      Polymorphism in C

      S 1 Reply Last reply
      0
      • S stgagnon

        A whipper-snapper (sort-of) on my team wrote this:

        for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
        

        I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        No, and this is really not the place.

        S 1 Reply Last reply
        0
        • S stgagnon

          A whipper-snapper (sort-of) on my team wrote this:

          for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
          

          I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          Quote:

          (systems[index].name, "XYZname")

          ?!?

          THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

          In testa che avete, signor di Ceprano?

          S S 2 Replies Last reply
          0
          • _ _Superman_

            Here's my take on this. If you need a minute to think about what a code statement does, then it has to go. Get rid of it.

            «_Superman_»  _I love work. It gives me something to do between weekends.

            _Microsoft MVP (Visual C++) (October 2009 - September 2013)

            Polymorphism in C

            S Offline
            S Offline
            stgagnon
            wrote on last edited by
            #5

            Thank you. My confidence is bolstered.

            1 Reply Last reply
            0
            • L Lost User

              No, and this is really not the place.

              S Offline
              S Offline
              stgagnon
              wrote on last edited by
              #6

              Sorry I bothered you. Please educate me: Where would you have posed the question?

              L 1 Reply Last reply
              0
              • CPalliniC CPallini

                Quote:

                (systems[index].name, "XYZname")

                ?!?

                THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

                S Offline
                S Offline
                stgagnon
                wrote on last edited by
                #7

                I know! The line does not even do what the coder intends it to do. Too bad the compiler did not complain. That alone is reason enough to 86 it, of course. This program is rife with this kind of stuff. Some of it may even work, but as Superman says, I should not have to spend more than a moment understand it..

                1 Reply Last reply
                0
                • S stgagnon

                  Sorry I bothered you. Please educate me: Where would you have posed the question?

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  The Lounge, or Weird & Wonderful. It's not a C/C++ question.

                  1 Reply Last reply
                  0
                  • S stgagnon

                    A whipper-snapper (sort-of) on my team wrote this:

                    for (index = 0; index < num\_systems && systems\[index\].type == SYSTEM\_TYPE\_XYZ && (systems\[index\].name, "XYZname"); ++index);
                    

                    I don't care very much for excessive cleverness. I care for maintainability. And debug-ability. This does not meet that requirement for me. Does anyone else feel this way? I am feeling old and curmudgeonly about this, however I want some honest opinions.

                    C Offline
                    C Offline
                    Chris Maunder
                    wrote on last edited by
                    #9

                    It's like a long paragraph with no commas or punctuation.

                    cheers Chris Maunder

                    1 Reply Last reply
                    0
                    • CPalliniC CPallini

                      Quote:

                      (systems[index].name, "XYZname")

                      ?!?

                      THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

                      S Offline
                      S Offline
                      Stefan_Lang
                      wrote on last edited by
                      #10

                      The result of that part of the condition would be the same as

                      static_cast(system[index].name)

                      The string literal will be evaluated but the result of the comma operator is always the leftmost argument. (You probably know that, but I thought I should offer an explanation for less experienced readers) My guess is this was supposed to be a string comparison. Not that it makes the condition look any better... Oh, and btw., I know that '??!' is the trigraph for '|', but I'm not familiar with '?!?'. Typo? ;P

                      GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                      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