CSE307
Spring 2009
Stony Brook
Principles of Programming Languages
Annie Liu
Assignment 5
Handout A5
Apr. 2, 2009
Due Apr. 16

Object abstraction --- Organizing everything

This assignment has two goals: (1) practicing programming with object abstraction, and (2) organizing everything we have programmed.

We have written programs for a variety of tasks: reading facts, parsing rules, computing statistics, analyzing names, and generating logic program code. We have used high-level data types, such as lists and sets, and control abstraction, such as comprehensions and recursive functions. We have also used classes and objects for the parsed rules and facts as given. However, we have not defined classes and created objects for organizing all these tasks (at least you have not been asked to, though perhaps you did on your own). We will do these now. We will continue to use all the files we used for Assignment 4.

Organizing everything

Specifically, we will organize and integrate our programs for all the tasks in Assignments 2, 3, and 4. Yes, this actually includes the task in Assignment 1 too, because that task is included in Assignment 2 where we used Python in place of other languages. There are three basic requirements for our organization.

First, the organization and integration should make all the tasks we did clear and modular, so that they are easy to understand and to use.

Second, our programs included alternative implementations of the same tasks in different assignments. So we should try to organize them to make it easy to use any and all of them.

Third, we should anticipate more processing tasks. So we should try to organize code for existing tasks to make it easy to enhance existing code and to add code for new tasks.

Of course, the organization is done by using object abstraction, discussed below. An additional requirement is that, however you will organize your code, you need to write justifications for why it is a good organization. Write justifications in your README file and comments, wherever appropriate.

Programming with object abstraction

How to best use object abstraction? In general, this is not an easy question, and my honest answer is that I am not sure and we need to work on the justifications. For what we have programmed, I will explain what I can think of, and you will have to be creative to try to find a best way and justify.

At least two kinds of uses of object abstraction are possible in what we have programmed.

  1. The data we have processed, i.e., rules and facts, can be represented as objects. As we all can see, we have already done this. For example, parsing of rules created objects of classes defined in file ehrparse.py.

  2. Different processing tasks could be captured by objects. For example, an object could do parsing of rules, another one could do name analysis, and yet another one could do logic program code generation. In fact, parsing of rules is already done by an object of class EhrParser in file ehrparse.py.
Could it be possible that these are not good kinds of uses of object abstraction? Could it be possible that some other kinds of uses are needed?

In any case, to organize and integrate everything, we would need to define classes and create objects. Perhaps, maybe, some existing ones need to modified? Perhaps, maybe, some ones could inherit from others?

Extra credit suggestions

Here are some ideas. (1) Think of good alternative ways to use object abstraction and to organize everything, implement them, and analyze their advantages and disadvantages. (2) Think of good ways to organize everything we did, and possibly more things we could do, on rules and facts into modules, implement them, and analyze their advantages and disadvantages. (3) Think of ways to analyze the types of the arguments of predicates, and do them; partial information about types counts too, such as some argument of some predicate always being a structure of some constructor. (4) Think of other interesting and/or useful things to analyze about the EHR policy, and do them. Feel free to discuss any of these with me.

Yes, there is no extra credit for early submission this time. I would like everyone to take time and try to find the best solution or solutions. Have a nice spring break!


Handins

Hand in everything electronically, using Blackboard, by 5pm on the due date. Your handin should include your README file, code, test data, and anything else you have to show your work.

Grading

This assignment will be graded based on 100 points, allocated in proportion to the estimated amount of work for each part. You may do this assignment in a team of two people; the two people will receive the same points. Exceptionally well thought-out and well written work will receive appropriate extra credit. Extra credit work will be graded based on the estimated amount of extra work.