473,626 Members | 3,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem converting a huge Program into small ones

Hi,
Recently my boss has given me a huge program (10000) lines of code.
The program has be written in an unmaintainable fashion.

It looks like someone who did not know programming has written it.

The program is written in such a fashion that it is a miracle that it is working.
Now, My job is to rewrite the program in a professional fashion.
The problem is where do i start. How to begin ?
Experienced programmers please advice.
Thanks,
James
Nov 13 '05 #1
7 1655
"James" <ja***********@ yahoo.co.uk> wrote in message
news:2f******** *************** ***@posting.goo gle.com...
Hi,
Recently my boss has given me a huge program (10000) lines of code.
The program has be written in an unmaintainable fashion.

It looks like someone who did not know programming has written it.

The program is written in such a fashion that it is a miracle that it is working.

Now, My job is to rewrite the program in a professional fashion.
Can you write a program from scratch in a 'professional
fashion?'
The problem is where do i start. How to begin ?
No offense intended, but if you don't know how to begin,
I suspect you're not the right person for the job.
I've had to do similar work more times than I care
to recall during my career -- it's typically no
simple task, even for folks with much experience.

A few times it was deemed more efficacious to rewrite
from scratch, instead of trying to 'fix' the 'spaghetti
code'. Of course your circumstances might prohibit this,
I don't know.

About all I can offer someone who says 'where do I start'
is to recommend Fowler's book "Refactorin g" and similar
works. See http://www.refactoring.com/

BTW your query isn't about C, which is the topic here.
Information on the topic, nature, and guidelines of
comp.lang.c:
http://www.angelfire.com/ms3/bchambl...me_to_clc.html
Experienced programmers please advice.


My experience combined with the nature of your request
and your apparent lack of direction causes me to advise
the hiring of someone who does know how to do it (best
if (s)he's done it a few times already.)

I'm not saying you're completely incapable of doing this,
but if there are time constraints, well ....

And don't forget the time needed for testing and debugging.

Final note: Don't try to determine what the program does
and how by reading the code. Read the specification.
If there isn't one, tell your boss you need one. You
might write one together, if you both have sufficient
knowledge of the program's purpose. You will have a
much better chance of success if you're coding to a
specific, detailed description.
HTH,
-Mike
Nov 13 '05 #2
James <ja***********@ yahoo.co.uk> wrote:
Hi,
Recently my boss has given me a huge program (10000) lines of code.
The program has be written in an unmaintainable fashion.

It looks like someone who did not know programming has written it.

The program is written in such a fashion that it is a miracle that it is working.

Now, My job is to rewrite the program in a professional fashion.

The problem is where do i start. How to begin ?


Since this a general programming question you'd do well to ask in
comp.programmin g.

You should start by finding the program specifications, and using those
to construct a series of black-box test cases that test all of the
boundary cases.

Then you can incrementally improve the program, re-running the tests
after each bit of work to ensure that it still meets the specifications.

You will probably need up to 4 or 5 passes of incrementally improving
the entire program before you'll be finished. So perhaps your *first*
step will be making sure that the boss knows it won't happen
overnight...

- Kevin.

Nov 13 '05 #3
Echoing what others have responded, this is really too vague a question for
us to answer. Without knowing the problems in the current programming and
the specifics with which it needs to be converted, it's very hard to give
some sort of advice. I've done this type of work many times and it seemed
to be quite different each time. Now, if you gave more specifics, I might
be able to give some pointers.
"James" <ja***********@ yahoo.co.uk> wrote in message
news:2f******** *************** ***@posting.goo gle.com...
Hi,
Recently my boss has given me a huge program (10000) lines of code.
The program has be written in an unmaintainable fashion.

It looks like someone who did not know programming has written it.

The program is written in such a fashion that it is a miracle that it is working.

Now, My job is to rewrite the program in a professional fashion.
The problem is where do i start. How to begin ?
Experienced programmers please advice.
Thanks,
James

Nov 13 '05 #4
James wrote:

Hi,
Recently my boss has given me a huge program (10000) lines of code.
The program has be written in an unmaintainable fashion.

It looks like someone who did not know programming has written it.

The program is written in such a fashion that it is a miracle that it is working.

Now, My job is to rewrite the program in a professional fashion.

The problem is where do i start. How to begin ?

Experienced programmers please advice.

Thanks,
James


Try to locate subunits of the program that do one specific task apiece.
Turn those into separately defined functions with suggestive names
(that is, the name should tell you what the function does). Each such
function should have one entry. It is best if it uses a fixed number
of arguments. Each subunit should be no more than a page long. In
fact, they should preferably be no more than a few lines each. If they
are longer, they are doing more than one thing.

This process of breaking out functional subunits with telegraphic names
is the essence of "factoring" .

You may need to define structs to facilitate communication between
functions. I have an example of factoring a longish subroutine into
smaller functions that increase the clarity of the whole. You can
find it at

http://www.phys.virginia.edu/classes...ogs/Cprogs.htm

Look at #5 on the list. There is a well-factored ANS Forth version,
an unfactored C version, and a factored version using structs. All 3
have been tested. Although the latter would be considered simplistic by
expert C programmers, several of the frequent posters to this group
held my hand while I did the version with structs. And I needed the
help.

Although your 10K line program (not huge, just moderately large; now
if you had said 100K lines ... ) is not likely to resemble my short
routine for adaptive integration, the techniques used in factoring
might be of help. Good luck.
--
Julian V. Noble
Professor Emeritus of Physics
jv*@lessspamfor mother.virginia .edu
^^^^^^^^^^^^^^^ ^^^
http://galileo.phys.virginia.edu/~jvn/

"Science knows only one commandment: contribute to science."
-- Bertolt Brecht, "Galileo".
Nov 13 '05 #5
"James" <ja***********@ yahoo.co.uk> wrote in message

Recently my boss has given me a huge program (10000) lines of
code.

Now, My job is to rewrite the program in a professional fashion.

The problem is where do i start. How to begin ?

Ask if you have the specification for the program. Probably it doesn't
exist. Ask if someone can draw one up. If they won't, ask how you are meant
to know if your version is bug-free without a spec.
This will all take time.

Then you fire up your C compiler and write a program that performs according
to the specification you have been given.
Nov 13 '05 #6
#1. Don't convert it.

#2. Don't even look at the source code, although it's probably OK to read
the comments.

#3. Get or create a functional specification. Get your boss to sign off
on the spec and, if possible, some kind of acceptance test.

#4. Design the program in a top-down manner, code it bottom-up.

#5. If you are having problems with specific functions, you can look at
the existing code, but don't use it unless it's clean. If it isn't,
create a black box that defines its operation and code the black box.

#6. You might remind your boss: "Good, Fast, Cheap. Pick any two."

--
#include <standard.discl aimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
Nov 13 '05 #7
On Fri, 26 Sep 2003 19:50:49 +0100, "Malcolm"
<ma*****@55bank .freeserve.co.u k> wrote:
Ask if you have the specification for the program. Probably it doesn't
exist. Ask if someone can draw one up. If they won't, ask how you are meant
to know if your version is bug-free without a spec.
This will all take time.

Then you fire up your C compiler and write a program that performs according
to the specification you have been given.

Listen to this man; he speaks wisdom.

--
#include <standard.discl aimer>
_
Kevin D Quitt USA 91387-4454 96.37% of all statistics are made up
Per the FCA, this address may not be added to any commercial mail list
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3332
by: hokiegal99 | last post by:
A few questions about the following code. How would I "wrap" this in a function, and do I need to? Also, how can I make the code smart enough to realize that when a file has 2 or more bad charcters in it, that the code needs to run until all bad characters are gone? For example, if a file has the name "<bad*mac\file" the program has to run 3 times to get all three bad chars out of the file name. The passes look like this:
2
9209
by: Henry | last post by:
Hi experts of Oracle, I used Oracle for small queries, but now I have a task to create WEB-based report by getting data, summarying ( several counts, min and max) and re-formatting, where the data are from around 10 tables, each of them is > 10k records, some larger ones have > 1 million records. Using sql*plus to count all records in a table took 25 seconds Since it is web-based, the number one concern for me is speed. Hope you...
8
1596
by: Pat | last post by:
I am using VC++ 6.0 to develop my program. class A { Object *obj public: A() { obj=new Object ; } ; }
4
3305
by: Cyde Weys | last post by:
I'm currently working on converting a simulator program from Visual Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but there's still one thing I haven't gotten to and I've never really had to deal with it before. I'm programming a front-end for what is a compiled Fortran program. The VB source does the following to call the Fortran: 'Defines the subroutine. Declare Sub Cycle_DW Lib "cycdw.dll" Alias "CYCDW" (ByRef...
17
16431
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee part of Manager is copied. ".... and gives the code above as .....
6
3171
by: ad | last post by:
I have a huge sting array, there are about 1000 element in it. How can I divide the huge array into small ones, and there are one 10 elements in a small one array?
39
3080
by: Marcin Zmyslowski | last post by:
Hello all! I have the following problem with MS Access 2003 permissions. I have two users. One is admin and the second one is user who has full permissions to enter modify and read data. I have one table and one queries which is based on this table. This query is good working for these two users.
15
2452
by: srampally | last post by:
The following code works in firefox. But IE displays the hyperlink at font-size=13 rather than font-size=10. Why? If its a known IE bug, how should I fix it? I always want the hyperlinks to take the size of the next parent element's class. thanks for the help, Shashi
5
2556
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I use to run a UM program, I kept on getting error messages. I have used someone else's implementation and it runs fine. I have compared my code with other's and I still can't figure it out what's wrong with mine. So please help me out, after 3...
0
8265
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.