Take-home Final Exam (Fall 2005)


COMP 204 Final Exam

Due Sat, Dec. 17 5:00 pm
This exam is open-book, open-notes, open-web, open-instructor, but closed-friends-and-classmates. Please sign a pledge here, and hand in this first page of the exam paper with your solution. Your signature signifies that you have done your own work within these guidelines.


(signature) ______________________________________________________________


(name printed) ___________________________________________________________

Overall, I want you to print this exam paper, attache your written solution to all the problems, and hand that in to me for grading. So, I want all problem solutions on paper to read.

Hand in the paper to my mailbox or office. In the paper you write, make sure you explicitly state for the problems with program parts something like "emailed attached program p1a.txt" or whatever (see special ML instructions following) so I will know to look for it and that you did not overlook the problem. There may well be other explanatory information needed for the program parts as well.

    Denotational Semantics

  1. [15%] Let's start with the denotational definition given in your class notes called "Example: language with combined expressions and commands".

    I wish to add to this language 3 new features:

    (1) normal For loop
        Syntax: for I = 1 to N do E
        Informal semantics: well known, I have no surprises in mind.
          If N is < 1, then go through the loop zero times. 
          If N is = 1, then go through the loop one time.
    
    (2) funky loop
        Syntax: loop E1, B, E2 end
        Informal semantics: B is an expression that is meant to evaluate to true or false; 
          the loop body is entered, and E1 is evaluated; then B is evaluated, and if
          true E2 is also evaluated and the loop goes back for another iteration; 
          however, if B evaluates to false, then looping ends and E2 is not evaluated
          on that last time thorugh.  This loop can implement both traditional while loops
          (E1 a null experssion), repeat loops (E2 a null expression), and hybrids.
    
    (3) 2-way multi-assignment
        Syntax: L1, L2 := E1, E2 
        Semantics: right-side expressions are all evaluated first,
        then assignments to left-side L-values are done in the 
        order written.  
    
        This is allowed: x, x := 2, 7 and would result in x having 
        the value 7 when done.  
    
    Modify the denotational definition by adding formal semantics for these three language features. You will need to add the syntactic BNF, the semantic functions, and the semantic equations that work off the BNF you create.

  2. [5%] Continuing in the spirit of the previous question, consider this n-way multi-assignment

    
        Syntax: L1, L2, ... Ln := E1, E2, ... En
        Semantics: right-side expressions are all evaluated first,
        then assignments to left-side L-values are done in some order;
        shown here in left to right order.
    
    Show an extenstion to the denotational definition from the previous question that defines the meaning of this n-way multiassignment. You can pick how you would want the order of assignment to go... you might, for example, find it easier to write a definition if assignment were "inside out", like this
        Syntax: L1, L2, ... Ln := En ...,  E2, E1
    
    It's your choice... pick your semantics, and formally define them. Make sure to tell me informally what you are trying to define.

    Design Patterns

  3. [80%] Suppose you have been tasked with developing a system for inventory control in a mail-order catalog retailing company. Your system must keep the catalog on-line (Web mania, you know, eCommerce and all that), keep track of how many of each item you have in stock, order more items from suppliers when low, take customer orders, maintain a shopping cart, make shipping orders, and arrange billing and collections. It should also keep statistics on what parts of the catalog are being visited by customers.

    In designing this system you, of course, want to use the best software engineering techniques to ensure that the final product is nicely extensible and easily maintainable. Your client is a growing company, so while they sell mostly books on-line right now, they expect to expand their product lines into CDs, videos, electronics, software... whatever the market seems to support. Your system must be designed to allow this expansion without business interruption.

    Sketch out a basic design for this system. Feel free to add your own details and enhancements to the (admittedly) very loose requirements given above.

    In your design description explain what object-oriented design patterns you have used, and why. To give a complete answer, you should not simply name the patterns, but rather for each pattern you choose to use, explain briefly what its structure is and give a rationale for using it in this design. Explain how your use of particular patterns will help reach your goals of an extensible and maintainable system.