Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-9617

Refactoring: Extract constant in function body to function parameter and adapt function uses

XMLWordPrintable

    • a6c8158484931c41e026b265297a1f2ae8a6e2c7

      The extract method refactoring is great, but often I realize that two sections of code are duplicated except for some constant. I'd like to highlight some constant value in a function and have qt creator create a function parameter and update all current uses of the function to call with that parameter. (or alternatively make the parameter default)

      example:

      bool searchFor(list foo) {
         for(auto it = foo.begin...)
            if(it == 7)  return true
          return false;
      }
      

      becomes

      bool searchFor(list foo, int NewParam) {
         for(auto it = foo.begin...)
            if(it == NewParam)  return true
          return false;
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            jbornema Joerg Bornemann
            millerhenry@johndeere.com Henry Miller
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes