Software Development: Re-usable Code: A Management Issue
Visual Basic Programmers, when given a task, will generally just sit down and start writing the code. Whether they are using an Object Oriented programming language or not, there is seldom a global view of all the previous work done by other programmers in their organisation.
All too frequently the same code is repeated in numerous programs and projects.
Duplicated code can be created by the same programmer over time, by the programmers in a team, by different teams, and by all the past programmers that ever worked in the company. So the reinventing of the wheel starts, and continues, and …
It is self evident that for any company to be efficient, it must automate. Yet the cost of computerisation can be high – highly trained Visual Basic programmers are expensive. And all too often the software produced is inflexible and costly to change.
Microsoft's Application Programming Interface
Microsoft sets a good example that is seldom followed. They provide commonly used and invaluable routines for programmers. They use these routines primarily for themselves and throughout the entire range of products, in creating and standardising their Windows Operating system. Microsoft has to be efficient if they want to survive. They try to eliminate all duplicate code in their software.
But programmers in a company seldom attempt to create common code. In most companies, once a routine has been written, it would take a brave programmer to attempt to rationalise code that has been working for years.
The Benefits of Re-usable Code
With Re-usable code, that is code that is not duplicated throughout an entire organisation:
- The programmer can build programs faster – and programs that run faster.
- Using less code means greater productivity and faster development cycles.
- Project hand-overs are easier for the programmer, with the familiar coding routines.
- By using the same code repeatedly by every programmer in every project, errors are quickly identified and eliminated.
- Re-usable code also benefits the organisation through greater end-user productivity. Users are more comfortable and need less training with standardised software programs.
Maximise code reuse so that a bug fix in one project will automatically benefit other projects.
Eliminating Repeated Visual Basic Code
As a Data Processing manager of a large company (in another life!), I had a team devoted to finding duplicated code in all the programs ever written. This involved searching through all the Source code used by the company. The duplicate code was identified and converted into centralised and Re-usable code for all to share. Errors were identified and eliminated – only the best variation of the code was used. Optional parameters allowed for the many variations of the functionality.
Then the redundant code was removed, and replaced by single line functions. This reduced the size and complexity whilst improving maintainability of each program. Using only the best, centralised and Re-usable code, controlled and documented by senior programmers, was an enormous productivity boost. Change management was simple – only one modification was need, to be immediately available to all programs. The programmers soon saw the advantage of the Re-usable code, and they started supplying suggestions on additional functions that could be rationalised.
Typical Visual Basic Code Duplication
The code that was commonly duplicated was:
- Database and Files – Opening and closing, reading and updating records
- Validation – Eliminating spurious characters like carriage return and line feeds.
- Formatting – Justifying text left, right and centre.
- Error handling routines – user level, recoverable errors and fatal crashes.
- Grid handling – Listing and updating database records.
Global Error handling routines
Converting the error routines into Re-usable code took on a life of its own. By having one centralised error routine handling all problems, statistics were produced to show the error count for each project and for each project team. This was a valuable management tool, partially to judge the quality of the programming, but mainly to determine which project needed additional resources or further analysis.
When important batch jobs were run overnight, a phone call system was initiated to advise the project leader of any problem. This, perhaps more than any other measure, improved the software quality dramatically. Programmers' partners were not amused at being woken up in the early hours of the morning!
Allocating Resources to code optimisation
Maximising code Re-use should be a fundamental goal of the professional Visual Basic programmer. Achieving this aim involves allocating time to this end – and reaping the benefits in greater productivity.