473,434 Members | 1,834 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,434 software developers and data experts.

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 1642
"James" <ja***********@yahoo.co.uk> wrote in message
news:2f**************************@posting.google.c om...
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 "Refactoring" 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.programming.

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.google.c om...
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*@lessspamformother.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.disclaimer>
_
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.uk> 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.disclaimer>
_
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
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...
2
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...
8
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
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...
17
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...
6
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
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...
15
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...
5
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...

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.