By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,436 Members | 2,979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,436 IT Pros & Developers. It's quick & easy.

Best way to modify code without breaking stuff.

P: n/a
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?
Jun 27 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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.

http://en.wikipedia.org/wiki/List_of...ntrol_software

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

I use SVN and mercurial.

Ivan
Jun 27 '08 #2

P: n/a
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ührer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

Jun 27 '08 #3

P: n/a
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
Jun 27 '08 #4

P: n/a
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ührer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

Jun 27 '08 #5

P: n/a
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.py" to "oldwhatever.py".

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

3. Create a new "whatever.py" 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("USENEWMODULE") == "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
Jun 27 '08 #6

P: n/a
On Jun 4, 3:44 am, Ivan Illarionov <ivan.illario...@gmail.comwrote:
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.

http://en.wikipedia.org/wiki/List_of...ntrol_software

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
Jun 27 '08 #7

P: n/a
Jesse Aldridge <Je***********@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.
Jun 27 '08 #8

P: n/a
On Jun 4, 4:44*am, Ivan Illarionov <ivan.illario...@gmail.comwrote:
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.

http://en.wikipedia.org/wiki/List_of...ntrol_software

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

I use SVN and mercurial.

Ivan
Also:

http://en.wikipedia.org/wiki/Regression_test
http://en.wikipedia.org/wiki/Design_by_contract
http://en.wikipedia.org/wiki/Test-driven_development
Jun 27 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.