473,287 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

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?
Jun 27 '08 #1
8 995
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

131
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately...
16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
29
by: pmatos | last post by:
Hi all, Sometimes I have a function which creates an object and returns it. Some are sets, other vectors but that's not very important. In these cases I do something like this: vector<int> *...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
22
by: stevenkobes | last post by:
If a word has a hyphen in it, IE will permit a line break at the hyphen, but Firefox/Mozilla won't. Apparently the Firefox behavior is standards-compliant, but it is not what I want. Is there a...
19
by: Johnny Google | last post by:
Here is an example of the type of data from a file I will have: Apple,4322,3435,4653,6543,4652 Banana,6934,5423,6753,6531 Carrot,3454,4534,3434,1111,9120,5453 Cheese,4411,5522,6622,6641 The...
7
by: Trickynick1001 | last post by:
Hi, a newbie here. I don't have a real firm grasp on the idea of Javascript, as I'm used to programming in Qbasic and C. I'm not used to OOP. Anyway, I really don't have any idea what the...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
7
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hello, I have an issue with some code I am updating: An entire file is loaded into a memory stream then that memory stream uses its WriteTo method to write to the responses output stream. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.