Best way to modify code without breaking stuff.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jesse Aldridge

    Best way to modify code without breaking stuff.

    I've got a module that I use regularly. I want to make some extensive
    changes to this module but I want all of the programs that depend on
    the module to keep working while I'm making my changes. What's the
    best way to accomplish this?
  • Ivan Illarionov

    #2
    Re: Best way to modify code without breaking stuff.

    On Wed, 04 Jun 2008 00:25:19 -0700, Jesse Aldridge wrote:
    I've got a module that I use regularly. I want to make some extensive
    changes to this module but I want all of the programs that depend on the
    module to keep working while I'm making my changes. What's the best way
    to accomplish this?
    Version control system.



    Make your module a versioned repository.
    Make your changes in different place, then commit them.

    I use SVN and mercurial.

    Ivan

    Comment

    • Ulrich Eckhardt

      #3
      Re: Best way to modify code without breaking stuff.

      Jesse Aldridge wrote:
      I've got a module that I use regularly. I want to make some extensive
      changes to this module but I want all of the programs that depend on
      the module to keep working while I'm making my changes. What's the
      best way to accomplish this?
      You simply run the module's unit tests that tell you if the new module's
      behaviour differs from the expectations. If you don't have unit tests, I'd
      say it's about time writing them.

      Uli

      --
      Sator Laser GmbH
      Geschäftsführ er: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

      Comment

      • =?UTF-8?B?QW5kcsOp?= Malo

        #4
        Re: Best way to modify code without breaking stuff.

        Jesse Aldridge wrote:
        I've got a module that I use regularly. I want to make some extensive
        changes to this module but I want all of the programs that depend on
        the module to keep working while I'm making my changes. What's the
        best way to accomplish this?
        Don't ;-)

        If the changes are that extensive it might be considerable to write a new
        module and switch the depending code to use that new module when you're
        done and they're ready.

        As mentioned in another posting revision control is a good thing as well.
        Not just for that task.

        nd

        Comment

        • Ulrich Eckhardt

          #5
          Re: Best way to modify code without breaking stuff.

          André Malo wrote:
          As mentioned in another posting revision control is a good thing as well.
          Not just for that task.
          From my point of view revision control is not a question but a fact.
          Seriously, if you are not using any RCS already, it is about time you start
          doing so. I even use it for my private toy projects.

          Uli


          --
          Sator Laser GmbH
          Geschäftsführ er: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

          Comment

          • Carl Banks

            #6
            Re: Best way to modify code without breaking stuff.

            On Jun 4, 3:25 am, Jesse Aldridge <JesseAldri...@ gmail.comwrote:
            I've got a module that I use regularly. I want to make some extensive
            changes to this module but I want all of the programs that depend on
            the module to keep working while I'm making my changes. What's the
            best way to accomplish this?
            If I'm understanding you correctly: you want to load the old module
            when running code normally, but want to use a new module when
            developing, but is has to have the same name?

            Here's what you could do:

            1. Rename "whatever.p y" to "oldwhatever.py ".

            2. Copy "oldwhatever.py " to "newwhatever.py ", and make your extensive
            changes there.

            3. Create a new "whatever.p y" with code that imports all the symbols
            from the old or new module depending on which module you want to use.
            For instance, you could use an environment variable to choose which
            one:

            if os.environ.get( "USENEWMODU LE") == "yes":
            from newwhatever import *
            else:
            from oldwhatever import *

            Or, you could set a flag in some sort of configuration module and
            check that:

            import config
            if config.use_new_ module:
            from newwhatever import *
            else
            from oldwhatever import *


            Carl Banks

            Comment

            • Carl Banks

              #7
              Re: Best way to modify code without breaking stuff.

              On Jun 4, 3:44 am, Ivan Illarionov <ivan.illario.. .@gmail.comwrot e:
              On Wed, 04 Jun 2008 00:25:19 -0700, Jesse Aldridge wrote:
              I've got a module that I use regularly. I want to make some extensive
              changes to this module but I want all of the programs that depend on the
              module to keep working while I'm making my changes. What's the best way
              to accomplish this?
              >
              Version control system.
              >

              >
              Make your module a versioned repository.
              Make your changes in different place, then commit them.
              That doesn't seem like a good solution for the OP's particular
              problem. To do it in a "different place", as you say, he'd have to
              check out a new working copy, which might be a bit of overkill
              depending on the size of the project. It could also be problematic to
              have separate working copies; there could be programs outside the
              project that are configured to use a certain location, for instance.

              One thing you could do with some version control systems is to switch
              the particular version for the module in question between different
              branches depending on whether you're using the tools or changing the
              model. (Subversion can do this, but I'm not sure if it's for
              individual files or only directories.)


              Carl Banks

              Comment

              • Paul Rubin

                #8
                Re: Best way to modify code without breaking stuff.

                Jesse Aldridge <JesseAldridge@ gmail.comwrites :
                I've got a module that I use regularly. I want to make some extensive
                changes to this module but I want all of the programs that depend on
                the module to keep working while I'm making my changes. What's the
                best way to accomplish this?
                Do you mean you want to hot-patch a running program? The short answer
                is: don't.

                Comment

                • Henrique Dante de Almeida

                  #9
                  Re: Best way to modify code without breaking stuff.

                  On Jun 4, 4:44 am, Ivan Illarionov <ivan.illario.. .@gmail.comwrot e:
                  On Wed, 04 Jun 2008 00:25:19 -0700, Jesse Aldridge wrote:
                  I've got a module that I use regularly.  I want to make some extensive
                  changes to this module but I want all of the programs that depend on the
                  module to keep working while I'm making my changes.  What's the best way
                  to accomplish this?
                  >
                  Version control system.
                  >

                  >
                  Make your module a versioned repository.
                  Make your changes in different place, then commit them.
                  >
                  I use SVN and mercurial.
                  >
                  Ivan
                  Also:




                  Comment

                  Working...