Software Development
Reusable Code – A Management Issue
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....
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.
It is self evident that for any company to be efficient, it must automate. Yet the
cost of computerisation can be high – highly trained technicians are expensive.
And all too often the software produced is inflexible and costly to change. With
reusable 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 handovers
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. Reusable code also benefits the organisation through greater end-user
productivity. Users are more comfortable and need less training with standardised
software programs.
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 reusable 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 the programs.
Using only the best centralised and reusable 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 reusable code, and they started supplying
suggestions on additional functions that could be rationalised.
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.
Converting the error routines into reusable 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!
Maximising code reuse should be a fundamental goal of the professional programmer.
Achieving this aim involves convincing senior management of the benefits and cost
savings of using reusable code, and that resources should be allocated to this end.
|