Not your grandma's textbook exercise

By Bertrand MeyerSeptember 1, 2022Comments View as: Print Mobile App Share: Email Share Share on reddit Share on StumbleUpon Share on Hacker News Share on Facebook

Share

Bertrand Meyer

In my eulogy for Barry Boehm last week in this blog, I mentioned from memory an exercise from his classic textbook Software Engineering Economics (Prentice Hall, 1981) . Now I got my hands on the book itself and found it to be even better than I remembered. Here is the text of the exercise in its entirety. This is Exercise 1.4, page 9. I hope that quoting an exercise from a 1981 textbook, even in full, is fair use.

They don't write manuals like this anymore!

Mary Jones from the accounting department tells you she has a personnel records file [update 2022: an Excel sheet] and asks you to expand a program to calculate the median age of staff in the file. Here are four different ways to respond:

(a) Invoke a sort routine that sorts the home folder by increasing age. Count the number, N, of personal folders in the file. Find record N/2 in sorted file extract its value for "age".

(b) Note that in The Art of Computer Programming [Knuth, 1973], Vol. III, pp. 209-220, the problem of obtaining the median is a special case of the problem of finding the ith largest of the N numbers, and that R.W. Floyd formulated a recursive method to obtain the median in an average of 3/2 N + O comparisons (N2/3 log N). Spend a few weeks trying (unsuccessfully) to improve Floyd's algorithm, a day programming Floyd's algorithm, then come back to Mary Jones with a few questions about her file size and format.

(c) Ask Mary how soon she needs the results, how much she is willing to pay for them, how many records, N, her home folder does she have, and how often she will be doing such errands. If N is large and she wants results often, quickly, and cheaply, ask her if she would be happy with the average value, which is much easier and cheaper to calculate. If not, work with Marie to adapt an approach to get the median that is the best compromise between her different goals.

(d) Calculate the average age and display it as the median. It's much easier to program, and Mary Jones will probably never notice the difference.

Rank responses in order of their relative concern versus programming considerations, economic considerations, or other important considerations. If you were the programmer, what approach would you prefer? If you were Mary Jones, which approach would you prefer?

Bertrand Meyer is Professor and Provost at the Schaffhausen Institute of Technology (Switzerland) and CTO of Eiffel Software (Goleta, CA).

No entries found

Not your grandma's textbook exercise
By Bertrand MeyerSeptember 1, 2022Comments View as: Print Mobile App Share: Email Share Share on reddit Share on StumbleUpon Share on Hacker News Share on Facebook

Share

Bertrand Meyer

In my eulogy for Barry Boehm last week in this blog, I mentioned from memory an exercise from his classic textbook Software Engineering Economics (Prentice Hall, 1981) . Now I got my hands on the book itself and found it to be even better than I remembered. Here is the text of the exercise in its entirety. This is Exercise 1.4, page 9. I hope that quoting an exercise from a 1981 textbook, even in full, is fair use.

They don't write manuals like this anymore!

Mary Jones from the accounting department tells you she has a personnel records file [update 2022: an Excel sheet] and asks you to expand a program to calculate the median age of staff in the file. Here are four different ways to respond:

(a) Invoke a sort routine that sorts the home folder by increasing age. Count the number, N, of personal folders in the file. Find record N/2 in sorted file extract its value for "age".

(b) Note that in The Art of Computer Programming [Knuth, 1973], Vol. III, pp. 209-220, the problem of obtaining the median is a special case of the problem of finding the ith largest of the N numbers, and that R.W. Floyd formulated a recursive method to obtain the median in an average of 3/2 N + O comparisons (N2/3 log N). Spend a few weeks trying (unsuccessfully) to improve Floyd's algorithm, a day programming Floyd's algorithm, then come back to Mary Jones with a few questions about her file size and format.

(c) Ask Mary how soon she needs the results, how much she is willing to pay for them, how many records, N, her home folder does she have, and how often she will be doing such errands. If N is large and she wants results often, quickly, and cheaply, ask her if she would be happy with the average value, which is much easier and cheaper to calculate. If not, work with Marie to adapt an approach to get the median that is the best compromise between her different goals.

(d) Calculate the average age and display it as the median. It's much easier to program, and Mary Jones will probably never notice the difference.

Rank responses in order of their relative concern versus programming considerations, economic considerations, or other important considerations. If you were the programmer, what approach would you prefer? If you were Mary Jones, which approach would you prefer?

Bertrand Meyer is Professor and Provost at the Schaffhausen Institute of Technology (Switzerland) and CTO of Eiffel Software (Goleta, CA).

No entries found

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow