Maintaining Badly Written Legacy Code
Category: How To Rewrite Articles | Mar 07, 2010 |

You have been handed a project or partly developed application to support. Due to prior deadlines, restricted budgets, limited developer skill, multi-developer miscommunication or just plain laziness from some previous developers you have been handed a maintenance nightmare. What steps can you take to improve this situation.
It is likely that you will not get the time to rewrite or refactor what is basically a mess, so small steps and a plan of action is needed:
- Do you have a prior list of complaints or help-desk calls that provide an overview of problems and priorities?
- Does the code have exception or error handling?
- How appropriately named are the variables? I have seen code with variables named aThingList and aColList.
- Is the code laid out in a way that makes it easy to understand the flow of instructions? I have seen code that was completely left-aligned making reading to understand it extremely difficult.
- Is there an infinite number of exponential loops within the code?
- Have you been left adequately written documentation about the application and any code and design decisions that were made.
First you need to tackle any commonly reported application problems. This often means finding the algorithmic cause of problems. Ideally you will be able to run a script over an uncompiled version of the application and replicate the error. Make a copy of any data sources the applications uses so that you can safely manipulate data without affecting the live system the users are using. If you can break into the code during an error or an exception then do so and step through the code line by line until you find the error.
If you cannot break into the code whilst the application is running then you will have to rely upon tracing code movement via a message notification, either using message boxes, writing to a file or writing the algorithm results to a makeshift debug screen. A notification at the entrance of a routine which includes the routine name and the time entered would be useful.
Once you have determined where the error is occurring you will need to determine why?
Is the data causing the problem? The best way to solve this problem is to improve data quality at the datasource. Perhaps an uploaded data file is not up to scratch. Perhaps the user is entering an unacceptable value. Even though the latter could be blamed upon the application’s lack of built-in ability to check user input, decisions made during it’s previous development phase could have put the responsibility upon the user to enter correctly formatted data which would make this a training issue not a data issue.
== ERROR-HANDLING ==
I have seen numerous applications’ code without any kind of exception/error-handling. You need to enter exception/error-handling into routines you know have errors and extraneously long routines. Within error notification you will need to display the routine name, error number and error message. For more information upon error handling see my article Exception/Error Handling, An Integral Part of Programming.
== BADLY NAMED VARIABLES ==
Usually there is not much you can do about a situation where the variable names are less than adequately descriptive of their purpose. Search and replace functionality may help you but usually will not discriminate between variables sharing the same name, in different areas of the cod,e that are used for different purposes. In fact, the renaming of an ambiguous name to a more purposeful name may complicate the understanding of the code where other variables of the same name are affected. The best practice is to write a comment next to the variable explaining it’s use for any particular routine within which it is found.
== CRUMMILY LAID OUT CODE ==
Either the code is all left-aligned or dischevelled: Reading badly laid out code is difficult in either case. If you have an editor that automatically indents code based upon language, cut and paste the code into your editor, realign the code and paste back into the application. If you do not have an editor and will be working with this code for some time, perhaps a quickly typed script to clean the code is in order. This is not as hard as it sounds. Basically all the script needs to do is count and add tab spaces whilst reading in each line of the code. If for example your script finds a While statement it adds a tab to the front of the next lines of code it reads in until it finds a Wend statement.
If an application’s existing code is particularly ugly and your job is only to add functionality to the application you may consider either removing the old code to a library so you will not have to look at it or build a module as an interface to the old code. The benefit of this is that you will only have to modify your interface should you need to make changes in the future. A added bonus is that you can comment your interface and remove your reputation from the extant disaster behind your it.
== INFINITE DO, WHILE, FOR LOOPS ==
My pet hate! If the code is not inextricably entwined within looping statements then try to reduce the complexity of a routine by extracting algorithms from the loop statements and placing the functionality within separate, smaller routines.
Document your changes via comments within the code or preferably use version tracking software to capture your changes.
== PROCESS IMPROVEMENT ==
Before embarking upon a plan of gradual improvement you need to do some investigation and find out whether there are any projects underway that could replace the application you have been handed. You do not want to waste time and effort patching up an application that will soon be replaced or defunct. Perhaps there are addins to other applications that can provide the same service to the users. Your goal is to get rid of the application if you can or reduce its negative impact upon workload (due to badly written algorithms) by farming out its tasks to better written and more stable applications. Maintenance is an expensive and time-consuming process for badly written applications.
If you cannot rid yourself of the application then write down some steps of improvement, for example; introduce exception/error-handling where it is lacking. Break down seriously long routines. Rewrite extremely bad legacy code that fails to live up to expectations. Remove ugly code to a separate library and access it’s functionality by a cleanly written interface. Perhaps you could introduce user input testing or format masks to force consistent data entry.
Sometimes an application produces reports with spurious results due to poorly devised calculations and inadequate testing of SQL string results. Provide users with data dumps in comma separated value (csv) files so they can build their own reports using spreadsheets and charting software (http://en.wikipedia.org/wiki/Comma-separated_values).
Do not be shy in discussing with your users the fact that you have been handed a lemon of an application, they will more than likely agree with you. Inform them on how you intend to implement a plan of process improvement and ask them for their thoughts and ideas. Remind them that it will be a gradual process and involve them in the development and testing. This is called the winning of hearts and minds! This concepts works because it is an inherently genuine and honest approach to improving the situation for your users and yourself.
Do not be disheartened by any user’s cynicism towards the services and plans you plan to offer them; When an application produces bad results for any period of time, prior promises upon which the previous developer was supposed to deliver have been broken and it is the user who suffers the results of those broken promises.
Lastly! Expedient support to users’ problems will be extremely appreciated even if your plan of improvement is slowed because of it.
Watch the video related to rewriting article how to
Help answer the question about rewriting article how to
Can someone suggest a good Article rewrite software?About Author
Duane Hennessy started programming in 1988 using FOCUS 4GL to create corporate databases. He took a brief hiatus to achieve his degree in Fine Arts (Printmaking) and came back to programming in 1998.
In 2004 Duane started his own company Bandicoot Software to provide high-quality useful software for individuals and development work.
During his day job Duane is a Senior Software Engineer specialising in MS Office integrated solutions and VBScripts providing imaginative solutions to complex business problems.
Man thats awsome!!!! Wow! How did you do this?! It looks like a photograph!!!
*Awesome
In other words, you want software that's smart enough to understand what it's given and intelligently rewrite it for you rather than just plug in potentially embarrassing synonyms?
I'm afraid there isn't any software that smart yet.
Sorry.
Rewriting an article is taking the original work and correcting errors and polishing it. This can involve taking out confusing passages or adding more descriptive words in place of mundane words. First thing to do is get Microsoft Windows Word. It has spell check, word count, will highlight in green when an obvious sentence fragment is present. Although it is limited and will not tell you when the format of the entire article is wrong.
Example:Does your article have a title that makes a statement or question? If so does the introduction paragraph restate the question or statement? Do you present solid points to confirm your stance on the topic? Do you have a conclusion paragraph that reiterates the thesis of the the article?
A good thing to do is to learn the Essay format they taught in school. An article is an essay, and it follows the same rules. There are a lot of rules but that doesn't mean there is no room to be creative and infuse your own brand of style into an article.
Go to this site http://www.constant-content.com/?aref=34458 where you can sign up (free) to write articles. The site tries to sell your articles are a price you name, and its a fantastic way to sharpen your skills. When there look at the forums, they are filled with great advice from other article writers and authors. I've been on the site for a few weeks now and have already learned more from the forums then years of classes.
Amazingg!
לא יאומן!!
If you're willing to try freeware programs, you may like to check on htttp://www.freewarefiles.com This is where I found things such as my anti-virus/spyware suites, Office sutie, etc. Hope it helps.
Contact some good article re writerss. I.e human s. You can find many sites like rentacoder.com. scriptlance.com etc who hires good rewirters.
Alternatively you can buy some articlere writerr software from the net. But be careful, many softwares does very shady work and google can ban you too for rewriting from such softwares. I happen to use one very good articlere writerr. Check the link
If you want a Lockerz invite. PM me your Email.
And I Promise I will send you a lockerz invite.
OMG it looks incredibly realistic and gorgeous! And beautiful music, by the way
wow dude that’s awesome! i love it
Hahaha. Well, clearly you didn't learn much about plagiarism when you were in college. I guess you just didn't get caught. Of course, if you do rewrite everything, anyone will tell you that getting caught it very uncommon.
There's a fine line here. If you're just re-writing or re-phrasing the whole article paragraph by paragraph, you've effectively copied it, and while it might be difficult to prove, you HAVE plagiarized the article. On the other hand, article concepts are not really something that anyone has ownership over. Imagine if they did. Once I wrote about something, no one else could ever write about that topic again…what a world that would be!
So, basically, if you're just rewriting articles directly, yeah, that would be a problem. On the other hand, if you're doing original writing, and just getting ideas from other places, I don't think that's particularly restricted. How do you draw the line between those two? Ah, that's where it gets tricky.
You might want to use the article writing / rewriting service from the web marketing company that I use to develop and promote my website.
holy fuck mannn
looks like johnny gettin high playin some pano
Well, with this question you are really comparing apples to oranges because each of these article softwares perform different functions. Let me explain, Mass Article Control is an article rewriter. It will take an article (called a seed article) and it will allow you to create hundreds of different or unique versions of that article (so as to avoid Google's duplicate content penalty).
Then you can take these articles and mass submit them to the thousands of different article directories on the web. So in effect you are submitting a slightly different version of the same article and thus building back links that Google will recognize and you will not get the duplicate penalty because of the different content of each article it has created. And yes, it does include an article submitter program that will submit your unique articles to the top article directories like ezine articles and article dashboard…Mass Article Control is a very powerful piece of software for article marketing.
MAC link: http://rds.yahoo.com/**http%3a//cli.gs/mass-article-control
Now, Unique Article Wizard will help you create completely unique articles (from scratch) on any subject you choose by pulling it's own research (fully automated) straight from the Internet and combining that research into a very readable article which you can then submit to the same article directories I mentioned before. So it is also a very powerful piece of software that performs a slightly different task than MAC.
UAW link: http://rds.yahoo.com/**http%3a//cli.gs/unique-article-wizard
I own both of these article softwares and they have helped me tremendously with my article marketing. I often get articles listed on page 1 of Google for the keywords I use in those articles. And I get tons of traffic from those Google listings.
The ideal situation would be to take UAW and create your seed articles then apply MAC to those seed articles and create hundreds of different versions – then submit those articles (with MAC) to the article directory websites for maximum effect. I hope this little explanation helps. Good luck in your article marketing efforts.