Feedback Discussion of assignment requirements 

Forum: U Chicago, Com Sci 221, autumn 2000
Re: News Assignment #5, due Monday 30 October (Mike O'Donnell)
Re: Question return information for assignment #5 (Michael C. Brizic)
Date: 2000, Oct 27
From: Mike O'Donnell <odonnell@cs.uchicago.edu>

So, it seems that there needs to be three separate functions called binary_search, insert, and find.
The assignment calls for two procedures: one to look up a telephone number given the name, and the other to insert a new entry in the telephone directory. Think of these as the procedures accessible in the user interface. Both of them require binary search, so it makes sense to code binary search as a separate procedure, in a form usable by both of the interface procedures. That requires a slight augmentation of the binary search required in the last problem, since you need to know where an item is found, or where it should be inserted. You also need to find or code a function to compare names, presumably in alphabetical order (although in principle the order is unspecified, and you can choose a convenient one).

To what extent will you grade against hard-coded code, because how will we be able to set up a phone directory unless we manually go into the array of structures and set each variable of each entry?
I'm not sure that I understand this question correctly. Since the user interface requires a function to insert entries in the directory, surely the most elegant approach is to start with an empty directory, and insert entries.

Also, what about the main function. Should this only ask for user input?
The design of the supporting code is your decision. It seems sensible to have it input insertion and lookup requests and provide output. It might also be handy to dump the whole directory contents occasionally, and to print out some of the internal variable values for testing.

If [the given name] is there, do you want the phone number returned along with a print statement saying something like, "Here is the number..."??
The assignment says, ``look up the telephone number for any given name, or give a special error message if the name does not appear.'' I think that the most natural interpretation of ``look up'' is that your procedure should return the telephone number. Since there is also personal vs. business information in the directory, one might argue for returning that, also, in a form that makes it easy to select out the phone number alone if that's what you want. Unless the purpose of a procedure is explicitly to print, it's usually bad design to put print commands in it. It's generally better to let your procedures produce values, and let the supporting code provide inputs and print outputs. That's because you often need to change programs so that basic utilities, such as table lookup, are used in different combinations from the ones you originally anticipated. If you tangle up output with the computing of values, you usually have to restructure all of your code. (I'm not referring to print commands that you put in for testing purposes. These are appropriate anywhere. They should print out intermediate values that are internal to the computation, more than final output values. They should be marked clearly as testing code, and they should be easy to disable either through conditional compilation or throught a test flag that you set at run time.)

Looking back at te problem statement int the assignment, I think that you might be confused a bit by the phrase, ``give a special error message if the name does not appear.'' The word ``give'' is ambiguous here. I think it's best to interpret it, at the level of the lookup procedure, to mean that you return some sort of value signifying an error. In the I/O support section, interpret that value as an error, and print a human-readable message. But, I don't suggest printing in the middle of the lookup procedure.

Also, doesn't the insert function call the find function, so I am thinking that if find returns print messages, it seems that it should return nothing, reference the information given to it by binary_search, and be void. But when insert calls it, it would appear that insert needs to know the location that find went to and could not find the phone number.
I find this question hard to follow, largely because of the heavy use of the pronoun ``it.'' I'm not sure precisely which thing ``it'' refers to at each spot. The phrase ``find returns print messages'' doesn't make a lot of sense to me. I think that you mean something like ``find prints messages.'' I think that this is the same issue that I addressed in the previous paragraph: it's probably a design error to have the lookup procedure print output. The latter half of your question suggests that you conceive of the user-interface procedure for insertion calling the user-interface procedure for lookup. That's probably a design error. It's probably better to have an internal binary-search utility that returns a location as well as an indication of whether or not the name is found (in fact, you may decide to leave the found/not-found indication implicit in the location, or to return it explicitly as a boolean value). Then both user-interface procedures call the binary-search utility.

And one more question, do you want us to write our own sort function to first sort the directory, or are we to set the directory up already sorted?
Sorting is definitely not part of the assignment. You may choose to sort in order to produce a directory for test purposes. Or you may just enter a sorted directory. If you like, you can test the behavior of your procedures on erroneous, unsorted directories. For some problems, robustnness and graceful degradation in response to input errors is important. For binary search in particular, I'm not aware of any interesting considerations along those lines. If I were doing the assignent myself, I would proably choose to start always with an empty directory, and produce interesting data by insertion. In effect, that's a kind of inefficient insertion sort.

Negotiating specifications

The discussion above goes through a number of modes of discourse, including some pedagogical discussion of principles in software design as they apply to this assignment. I want to draw your attention particularly to another aspect of the discussion that might be misconstrued. Because of our conventions about teaching and studying, we tend to view the questions and responses regarding the precise meaning of the assigned problem as the clearing up of unfortunate confusion, and to wish that either my statement of the problem or your understanding of it were clearer and more direct. On the contrary, I think that this sort of negotiation of the problem specification is an unavoidable, incredibly important, and often neglected part of the real action in software creation. It turns out to be impossible in practice to first write a clear specification of what software should do, and then do it. Even when the specifier is an expert, this doesn't work. Rather, specifications are negotiated between those providing the requirements and those doing the implementation. Part of the negotiation involves clarification of requirements, which is involved in our discussion above. The more sophisticated the project, the more likely that the negotiation will also involve changes in the requirements in response to implementors' feedback on feasibility and cost, and to users' early experience with prototypes. I definitely intend that part of each assignment is to go through this sort of discussion in order to home in on the best possible work.



Mike O'D.


to: "Discussion of assignment requirements"