Stanford University
Computer Science 349: Winter 2004 - 2005

CS349 Midterm 2005, Take home exam


Due: 5 pm PST, Feb 18th 2005. Please submit by email to cheriton at dsg.stanford.edu.

You are free to use any material, including books, course material, etc. However, you should complete the exam yourself without assistance from others. It is a violation of the honor code to receive assistance from others or to copy material without proper attribution.

Feel free to use point form. Each question can be answered satisfactorily in a page of writing or less. I am primarily interested in the most key points responsive to each question.


  1. Software Engineering: "If it is not quantitative, how can it be engineering?" List 3 key quantitative measures that should be used more in software engineering and briefly describe how their use could be improved, or, how software design could be improved to facilitate this measure.
  2. Audit: In comparison to inline checking, audit only detects a problem at time of audit, which may be long after the problem arose. What are the trade-offs between inline (asserts and pre/post condition) and non-inline checking (as in audit) and why would you conclude they favor audit over inline checking, or argue the oppposite if you prefer.
  3. Collections and Iterators: Describe three key issues that arise with the semantics of iterators and what you see as the best approach in each case, with some appropriate rationale.
  4. Templates: C++ templates have ended up being "Turing complete", allowing complex calculations and constructs to be performed as compile time. Outline the cost-benefit trade-offs in using templates and give a compelling example of good use in this trade-off, and an example where the use is not justified by this trade-off.
  5. Value Types: At first thought, it would seem hopeless to provide class templates using for easing the burden of defining value types, given the combinatoric explosion in the number of possible operations. For example, naively, you might imagine one value type defining equality and addition but not multiplication and division, while another defines multiplication but not relational operators. The powerset of possibilities is enormous. List the key techniques used in Chapter 14 that make a small number of class templates actually useful, indicating how they do so.

The End