This is an open-book, open-Internet exam. Don't talk to people other than Jeff Ondich about this exam. If you get ideas from web sites or books (I'm asking for arguments and opinions in some cases, and you may find yourself seeking ideas on the web), provide thorough citations.
(5 points) Summarize the arguments for and against comments. Be clear and concise. Include two brief examples of situations where you consider comments essential, and two brief examples of bad comments.
(5 points) Summarize the arguments in favor of assertions. In what situations are they obviously valuable? What, if any, dangers does their use pose? Summarize the arguments for and against leaving assertions turned on in shipping code.
(8 points) Six months after graduating in 1998, one of our CS majors who went off to become a programmer wrote to me raving about a paper that I needed to read and then start teaching to my students. The paper, "Hungarian Notation" by Charles Simonyi of Microsoft, describes Simonyi's naming system for identifiers (variables and constants, in particular). I'm having trouble finding an original citation (or title, for that matter), but there are copies of the paper at Microsoft and elsewhere.
Read Simonyi's paper, and then answer the following questions.
(2 points) Tell me a joke, or recommend a book or movie. I promise to laugh, read, or watch. Really.
(10 points) Design patterns.
What problem is the Abstract Factory design pattern trying to solve? Summarize briefly the solution given by this pattern.
For the past few weeks, I have been working off-and-on on a C++ character string class that can deal with different byte orders (big endian versus little endian) and different encodings (1-byte ASCII, 2-byte Unicode (UCS-2), 4-byte Unicode (UCS-4), UTF-8, etc.). Suppose my string objects can be in various states, such as "big-endian UCS-2" or "little-endian UCS-4", but that I always want to support reading lines of text from an istream object. Show me how I could exploit the State design pattern in this situation. In particular, give me a UML diagram of the classes and methods I should implement to give my string objects the flexibility to do different kinds of input depending on their different states.