CS 3500   Spring 2010
Object-Oriented Design


 

Overview

Official summary: The course presents the theory and practice of object-oriented programming. The course enhances students understanding of the concepts of object, class, message, method, inheritance, and genericity. The course covers a basic model for objects; the principles of types and polymorphism in object-oriented programming languages; different forms of abstraction; and theory and practice of reuse. The course also introduces students to some object-oriented design patterns that practitioners have found useful.

 

Announcements   [RSS]

Wed, 21 Apr 2010: Here is my updated final exam information. First, from the registrar's office, the exam is Monday, April 26th, 8:00-10:00, in Robinson Hall 409. The format of the final will be that of the midterm, so half "theoretical" questions and half "practical" questions. Just like the midterm, you have the right to a double-sided 8.5"x11" cheat sheet. Other than that, closed books and closed notes and closed computers.

Wed, 21 Apr 2010: Here are the Submission Instructions for Homework 6 --

(1) Write a README text file giving your team members, and describing the extensions to the game you have made: what extensions you made, what classes you added, interesting bits about implementation of those classes, even a sample execution of the game showcasing your extensions to the game.

(2) Zip up all the source code of your game, as well as your README file, into a file called homework6.zip. The idea is that I should be able to compile your whole game using your submitted file, without messing with it.

(3) Go to the submission site and submit your zip file. Only one submission per team is necessary.

Tue, 20 Apr 2010: Here is the final review list from this morning's lecture. This morning, I also talked about abstracting control-flow, and gave a continuations-based example in Scheme. Here is an interesting and short article that highlights continuations in Scheme and shows how to use them to implement other control-flow mechanisms, such as exceptions, and time-traveling search, among others. I mentioned that continuations were useful to understand web programs; the following article gives a sense of what I mean. For the more technically inclined, you may find the following article interesting.

Fri, 16 Apr 2010: Here is a link to a decent Python tutorial. I've uploaded the code from this morning's lecture, List.py, as well as a sample session with the code, a bit different in the details from what I did this morning, but similar in spirit.

Fri, 09 Apr 2010: Lecture notes for this morning's lecture on the Model-View-Controller design pattern are now available. I also provided the source code for the lecture.

Tue, 06 Apr 2010: I'm canceling class and office hourse today, seeing I lost my voice because of a cold. I'll hold make-up office hours this Friday, 15h00-17h00.

Mon, 05 Apr 2010: A quick look at Banner seems to indicate the following time for our final exam: 8:00am - 10:00am M Apr 26, 2010 .

Sun, 04 Apr 2010: A bit late because of the flu, but homework 6 is up. Due Sunday, April 25th. There is a lot of support code for this one.

Sat, 03 Apr 2010: Lecture notes for Friday's lecture on the Publish-Subscribe design pattern are now available. I also provided the source code for the lecture.

Wed, 31 Mar 2010: Notes for Tuesday's lecture on the interaction of subclassing and mutation are now available.

Fri, 26 Mar 2010: Notes for this morning's lecture on adapters are now available.

Thu, 25 Mar 2010: In the specification of MovieB in Question 3, the signature of the numberFrames() method should indicate it returns an Option<Integer>, and not an int. The code gets this right.

Tue, 23 Mar 2010: Lecture notes for this morning's lecture on mutation are now up.

Tue, 23 Mar 2010: A student just pointed out to me that my description of behaviors is missing something important. Intuitively, the scale(str) behavior takes a streams str of floats and produces (via an iterator) a sequence of transformations that scale a frame around its center by the specified ratio, using the scale() operation on frames. The rotate(str) behavior takes a stream str of floats and produces a sequence of transformations that rotate a frame around its center by the specified degrees, using the rotate() operation on frames. I've updated the homework write-up.

Tue, 23 Mar 2010: Here are a couple of sample files for testing your homework 5 code. First, to try out your MFrameB implementation, here's TestMFrameB.java, that has a couple of sample frames to try out your translate, rotate, and scale functions, independently, and all together. Pick one of the four tests (comment out the others, only the last one will actually show), and try it out. Here are the outputs that testTranslate(), testRotate(), testScale(), and testAll create, respectively:

To try out your behaviors and movies, use TestMovieB.java, which constructs three behaviors (a cross movement behavior, a spinning-in-place behavior, and a smaller-then-bigger behavior) and applies them to the boy sprite. Again, there are four tests available, choose one and comment the others. (Otherwise, only the first one will actually run.)

Sat, 20 Mar 2010: Lecture notes for Friday's lecture on multiple inheritance and ADT extension are now up. Let me know if anything is amiss.

Mon, 17 Mar 2010: Homework 5 is up. Due Friday, March 26th. There are a bunch of support files available for this homework.

Tue, 16 Mar 2010: In case you're waiting with bated breath, I'm still hacking on homework 5, and I expect to get it out tomorrow morning.

Tue, 16 Mar 2010: Lecture notes for this morning's lecture on inheritance and delegation are now up. They're a bit rough around the edges, so let me know if anything doesn't actually make sense in there.

Fri, 12 Mar 2010: Lecture notes for this morning's lecture on laziness are now up. I also provided the source code for the lecture.

Fri, 12 Mar 2010: A couple of comments about homework 4, due tonight. First off, some people spotted the fact that the specification for Overlay(m1,m2).funcIterator().moveToNext() in Question 3 is missing. Indeed. Oversight on my part. Here's what moveToNext() should do: it should move both of the underyling iterators for m1 and m2 to the next element, leaving either one unmoved if it's out of elements.

Second, the implementation of equals() for Question 1 is headachy because Option is a polymorphic class. Rather than having you figure it out yourself, here is the implementation of equals() for both concrete subclasses of Option. For none():

   public boolean equals (Object obj) {
       if (obj instanceof Option) {
           @SuppressWarnings("unchecked")
           Option foo = (Option) obj;
           return foo.isNone();
       }
       return false;
   }

And for some():

   public boolean equals (Object obj) {
       if (obj instanceof Option) {
           @SuppressWarnings("unchecked")
           Option foo = (Option) obj;
           return (!foo.isNone() && foo.valOf().equals(this.value));
       }
       return false;
   }

Thu, 11 Mar 2010: Some of you have asked for a couple of sample movies for trying out your code for homework 4. Here's one, MovingBoys.java, that creates a movie made up of the overlay of three smaller movies that move a simple sprite in the canvas window.Here are the three snapshots from the movie:

Thu, 11 Mar 2010: Lecture notes for Tuesday's lecture on the Map and Reduce design patterns are now up. I also provided the source code for the lecture.

Tue, 09 Mar 2010: Midterm results posted to Blackboard, and were distributed in class this morning. If you missed yours, I'll try to remember to bring it in on Friday. And I wasn't too far off: the average on the midterm was 41.31, with a standard deviation of 6.56.

Sat, 06 Mar 2010: Than reports a small typo in homework 4. It should not cause any problems, but just in case: The line with public static Option<Integer> mimimum (List<Integer> lst) should define function minimum not mimimum.

Mon, 01 Mar 2010: Homework 4 is up. Due Friday, March 12th. There are a bunch of support files available for this homework, including an implementation of the Sprite ADT from homework 3.

Sat, 27 Feb 2010: Lecture notes for Friday's lecture on functional iterator gadgets are now up. I also provided the source code for the lecture.

Wed, 24 Feb 2010: Here is a list of topics that you should know for the midterm.

Tue, 23 Feb 2010: One thing came up in question 2 of homework 3: some of the math asks you to divide values. Because of the way Java is designed, if you try to divide two integers, the result will be rounded to an integer. Which means that, if you're not careful, you easily end up with 0s -- for instance, when evaluating 3/5. The solution is to cast one of the integers to a float before dividing (that will force Java to use floating-point division). Or, if you prefer, just use the following function div to divide integers:

    public static float div (int i, int j) {
      return ((float) i)/j;
    }

Tue, 23 Feb 2010: First, if you haven't picked up your graded homeworks 1 or 2 yet they're in a box outside my office, in WVH 328.

Second, extension for homework 3, until Thursday night, 22h00.

Finally, we have a midterm this coming Friday, in class. Closed-books exam, but I'll let you bring in a single double-sided 8.5x11 crib sheet. The exam covers everything we've seen in the semester. I'll post a broken down list of things to be sure to know later today. Watch this space.

Mon, 22 Feb 2010: Some of you are crunching hard on homework 3, and having some difficulty with question 2, on the Picture ADT. Well, it is a bit subtle. So here's a suggestion. First off, identify the creators of the ADT, and follow the Specification Design Pattern (see lecture 7). Don't implement the drawIterator() operation just yet. Implement the following operation instead, one that counts the number of lines in a picture: here is the signature of the operation:

   public int countLines ();

with the following specification:

   nil().countLines() = 0

   sprite(sp).countLines() = countElements(sp.funcIterator())

   flip(p).countLines() = p.countLines()

   rot(p).countLines() = p.countLines()

   overlay(p).countLines() = 2*p.countLines()

   beside(n,p,m,q).countLines() = p.countLines()+q.countLines()

   above(n,p,m,q).countLines() = p.countLines()+q.countLines()

where countElements() is the function that counts the number of elements from an iterator that we saw in class and in the notes (suitably modified to work with FuncIteratorLine) -- you can just make it a private function in the class you're writing, as a helper function. If you can get the Picture ADT going with the above operation and without the drawIterator() operation, then you're in very good shape. You can just focus on the drawIterator() bit after.

You don't have to do any of the above, of course. This is just to help you.

Mon, 22 Feb 2010: Jonathan pointed out that I messed up in my last posted file MainMan.java -- my code used FuncIterator<Line> instead of FuncIteratorLine, since I told you not to worry about polymorphism for this homework. The file has now been corrected, and the web site should have refreshed. If for some reason the change does not propagate fast enough, you can just replace all instances of FuncIterator<Line> by FuncIteratorLine in the file, by hand.

Mon, 22 Feb 2010: Here are a couple of files implementing some sample pictures for you to try out your code. First, MainMan.java, that creates three pictures and displays them in the canvas. (You need to click the canvas to move to the next picture. See the code.) Here are the three pictures you should see:

Second, MainArrow.java, that also creates three pictures and displays them in the canvas. (And again you need to click the canvas to move to the next picture. See the code.) Here are the three pictures you should see:

Sat, 20 Feb 2010: Final version of the lecture notes for Friday's lecture are now up. I've added the bit about polymorphic pairs and polymorphic addable pairs, stuff that I did not have time to do in class. I also provided the source code for the lecture.

Sat, 20 Feb 2010: Lecture notes for Friday's lecture are partially completed and are up. I've posted them as is, and will complete them probably later tonight or tomorrow.

Sat, 20 Feb 2010: A few of you spotted the big typo in homework 3: the signature of drawIterator in the Picture ADT has a spurious void in it. It should read:

public FuncIteratorLine drawIterator (Point, Point, Point);

I've updated the write-up (although the refresh rate of the website seems too low for my taste).

Wed, 17 Feb 2010: Midterm -- we agreed that having the midterm before Spring Break was a good idea. So that makes the midterm date Friday February 26th, during class. It should cover everything until next Tuesday. I'll do a quick review on Tuesday.

Wed, 17 Feb 2010: Lecture notes for yesterday's lecture on polymorphism (aka generics) are up. I've also made available a fairly clear tutorial on polymorphism by Bracha, responsible for the addition of polymorphism to Java. I'll cover defining polymorphic classes on Friday.

Mon, 15 Feb 2010: Got the following question by email today, the answer will probably be useful to the lot of you:

Since question 1 asks us to submit only one file, should we just add the 2 subclass(EmptyFuncIteratorInt & SpriteFuncIteratorInt), but put the public interface FuncIteratorInt to an other separate file? and not submitting the interface?

The answer is yes, on both counts: (1) put your auxiliary subclasses for the iterator in the same file as Sprite and (2) put the public interface FuncIteratorInt in its own file, but don't submit it. We have our own. (This means of course that you should not change that interface...)

Fri, 12 Feb 2010: Homework 3 is up. Due Tue, 23 Feb. If you go to the course web page you can find the class CanvasWindow that implements the window in which you can draw, and reference classes Point, Line, and Sprite from homeworks 1 and 2 so that you are not penalized if you messed them up.

Fri, 12 Feb 2010: Lecture notes for this morning's lecture on functional iterators are up. along with the code. Please note that I've changed the name of the interface for functional iterators to FuncIteratorInt to emphasize that they're functional iterators that yield integers. That will avoid name clashes later on. Homework 3 is coming out later tonight.

Tue, 09 Feb 2010: Lecture notes for this morning's lecture on subclassing from multiple classes (including Java interfaces) are up.

Tue, 09 Feb 2010: In case you forgot it or ditched your email, here is the submission web site.

Fri, 05 Feb 2010: Lecture notes for Friday's lecture on various topics in subclassing are up. Includes both the use of nested classes in the Specification Design Pattern, and the distinction between compile-time and run-time types, as well as dynamic dispatch. Sorry it took so long, but I struggled a bit to try to make things clear.

Tue, 02 Feb 2010: I distributed graded homeworks 1 this morning. Your grades are available (as will all subsequent grades) on the course page on Blackboard. Please make sure that the grades that are posted actually agree with what you get back -- I'm counting on you to keep it error-free.

Tue, 02 Feb 2010: Lecture notes for this morning's lecture on code reuse via subclassing (including the Specification Design Pattern) are up.

Fri, 29 Jan 2010: There we go: lecture notes for this morning's lecture on software testing are up.

Fri, 29 Jan 2010: Here are the testers for Line and Sprite. I may be playing with them somewhat over the weekend to soften up the rough edges, so you may want to keep an eye out for updates, announced here. Okay, next up, lecture notes.

Fri, 29 Jan 2010: Homework 2 is up. Due Tue, 09 Feb. I will post the promised testers for questions 2 and 4 later tonight. Also, you will not be able to answer question 3 until next week when we see the Specification Design Pattern, but until then you can do questions 1 and 2.

Tue, 26 Jan 2010: Notes for this morning's lecture on errors and exceptions are up.

Tue, 26 Jan 2010: If you have not received your registration information for the submission web site, please send an email to our TA Jon at jhoag@ccs.neu.edu.

Mon, 25 Jan 2010: An email was sent to each of you this afternoon containing information about the submission system and how to register for it. That email was sent to your HuskyMail account, the one that ends with husky.neu.edu. Please check it.

Sat, 23 Jan 2010: Notes for yesterday's lecture on equality for ADTs are up.

Thu, 21 Jan 2010: Here is a tester that you can use to test your implementation of the Point ADT for homework 1. Compile it with your code, and run it, it will test your implementation against the specification, except for the equals method, which I will talk about tomorrow.

Tue, 19 Jan 2010: Notes for this morning's lecture on ADT implementations in Java are up , as well as the code that I used.

Tue, 19 Jan 2010: Homework 1 is up . Due Tue, 26 Jan.

Mon, 18 Jan 2010: Notes for Friday's lecture on ADTs and algebraic specifications are up .

Wed, 13 Jan 2010: Notes for the introductory lecture yesterday are up .

Mon, 11 Jan 2010: I'm setting up the RSS feed for the course. You should see an RSS link up in your browser. And welcome, by the way.

 

Course Information

Time and Location: Tue/Fri 11:45-13:25 108 West Village H (#23H)

Instructor: Riccardo Pucella, 328 West Village H (#23H)

Office hours: Tue 15:00-17:00

Teaching Assistant: Jonathan Hoag (WVH 330, Office hours: Mon/Wed/Thu 13:30-14:30, email jhoag@ccs.neu.edu)

Course Web Site: http://www.ccs.neu.edu/home/riccardo/cs3500

Prerequisites: CS 2510

Textbooks: No textbook for the course. I will post lecture notes here. You may find the following books useful, although they are not required:

  • C. Hostermann, Object-Oriented Design and Patterns, 2nd edition, John Wiley and Sons, 2006
  • P. Sestoft, Java Precisely, 2nd edition, MIT Press, 2005.

Grading: Grading will be based on weekly homeworks (50%), a midterm (25%), and a final exam (25%).

There may also be one or more quizzes, which may count as either assignments or exams at the whim of the instructor.

While some program assignments may require students to work in teams, most assignments and all quizzes and exams are individual. Student work is subject to the Academic Honesty and Integrity Policy.

Security is an important aspect of software development. In this course, students are expected to protect the software they develop from plagiarism. The quality of this protection will be graded.

 

Schedule Outline and Lecture Notes

This schedule is subject to change without warning. Readings will be assigned to supplement lectures, and posted here.

Jan 12

Introduction

- Lecture notes

Jan 15

ADTs: algebraic specifications

- Lecture notes

Jan 19

ADTs: implementation in Java

- Lecture notes
- Code

Jan 22

ADTs: equality

- Lecture notes

Jan 26

Errors and exceptions

- Lecture notes
- Java Tutorial on Exceptions

Jan 29

Software testing

- Lecture notes
- Programming with Assertions

Feb 2

Code reuse: Subclassing

- Lecture notes

Feb 5

Topics in subclassing

- Lecture notes
- Java tutorial on packages

Feb 9

Subclassing from Multiple Classes

- Lecture notes

Feb 12

Design pattern: Functional iterators

- Lecture notes
- Code

Feb 16

Polymorphism

- Lecture notes
- Code
- Java tutorial on generics
- A more technical tutorial by the person responsible for getting polymorphism into Java

Feb 19

Polymorphism (continued)

- Lecture notes
- Code

Feb 23

Examples: Iterator Gadgets

- Lecture notes
- Code

Feb 26

Midterm

 

Mar 9

Design Patterns: Map and Reduce

- Lecture notes
- Code

Mar 12

Design Pattern: Laziness

- Lecture notes
- Code

Mar 16

Code Reuse: Inheritance and Delegation

- Lecture notes
- Java Tutorial on Inheritance. Note how they conflate inheritance and subclassing.

Mar 19

Multiple inheritance

- Lecture notes

Mar 23

Mutation

- Lecture notes

Mar 26

Design pattern: adapters

- Lecture notes

Mar 30

Subclassing and Mutation

- Lecture notes

Apr 2

Design pattern: publish-subscribe

- Lecture notes
- Code

Apr 9

Design pattern: model-view-controller

- Lecture notes
- Code

Apr 13

Mixins in Scala

- The Scala programming language
- Programming Scala, from O'Reilly

Apr 16

Iterators in Python

- The Python programming language
- The Python tutorial
- Code for lists from class
- Sample session using the code from List.py

Apr 20

Odds and Ends

Final review

 

Homeworks

Removed

 

Online Resources