Subj : Re: Is well written code a rare species ? To : comp.programming From : Scott Moore Date : Mon Aug 15 2005 05:11 pm Alan Balmer wrote: > On Mon, 15 Aug 2005 11:03:13 -0700, Scott Moore > wrote: >=20 >=20 >>Ilpo Nyyss=F6nen wrote: >> >> >>>>That's the wrong place to start. First you need to write a fresh >>>>functional specification for the program that includes all of the >>>>features you want it to have, and how it should operate. Then >>>>you can work on a new design of the program. Then, having >>>>gone to all that effort, do a complete rewrite of the code. >>> >>> >>>How do you do that with a big program with something like a million >>>lines of code containing quite big amount of features? >> >>By breaking it down in to smaller, more manageable pieces. >=20 >=20 > In other words, rewrite it. I don't think that answers the question. The OP said he/she might have a "million lines of code". Assuming that was not just said to impress, look at what it says about how the programmer thinks about the code. They didn't say "100 modules of, say, 10,000 lines each". It tends to imply 1 million lines of somewhat to not very modular code. Such a codebase is certainly in trouble, whats amazing is not that it got to 1 million lines of code, but that it works at all. Such a program or system, rewritten to overcome its faults, will result in a 1 million line system or program that works as well as the original 1 million line program or system. So the question was: >>>How do you do that with a big program with something like a million >>>lines of code containing quite big amount of features? The answer was break it down in to smaller modules. I would further say that even if such a rewrite were comtemplated, that breaking it down into modules would be, or should be, a required first step. It would both= identify the modules, as well as greatly assist the rewrite, since it could now be rewritten one module at a time. We probally have somewhere near 1 million lines of code in our project. However, nobody keeps such a statistic, since there is no demand for it. More interesting is the number of modules, and perhaps how many source lines in each. Also, the total number of core bytes occupied. I have never worked for a shop that didn't have programmers crying "rewrite!" on occasion. In principle, rewrites are never necessary, but in real world companies, they are. However, there are factors to rewrites= that should be considered: 1. The company that created the need for the rewrite is (usually) the one= who will carry it out. 2. The ones who are best positioned to carry out the rewrite, are the one= s who did the original code, since (we presume) they have learned from thei= r mistakes. Otherwise, it may well occur that the exact same mess is create= d anew. And yes, this obviously conflicts with factor (1). 3. The best code is usually created when the project (rewrite or otherwis= e) is small and coherent. As the program and the group of people programming= it become large and tired, the system will start to degenerate. This is why programs need rewrites, and is the factor ignored when considering a rewrite. I have participated in very few rewrites, and even fewer that suceeded. The ugly fact is that most programs stop functioning when the companies that made them either discontinue the product, or stop functioning themse= lves. .