473,386 Members | 1,821 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,386 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 997
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. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.