CS 3500   Fall 2009
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, 16 Dec 2009: I will accept homework 6 until tonight, 22h00.

Sun, 13 Dec 2009: First off, I am a bit behind on email replies, sorry about that. But I'll get to them by tomorrow morning. Second, I mentioned you could have a cheat sheet on the final: a single sheet, 8.5x11, double-sided.

Thu, 10 Dec 2009: Here is the information from Banner about the final exam:

Final Exam 1:00 pm - 3:00 pm W Shillman Hall 305 Dec 16, 2009

Wed, 09 Dec 2009: I have a bunch of Google Wave invites still available. If you want to try it out, drop me an email. First come first serve.

Wed, 09 Dec 2009: The submission site for submitting homework 6 is up and running. As I said, I will accept homeworks until the day of the final exam. Please call your zip file spacegame.zip, to simplify my life.

Tue, 08 Dec 2009: Lecture notes for this morning's lecture on factory methods and reflection are up. They include a quick review of the topics on the final exam -- basically everything up and and including the MVC design pattern.

Sat, 05 Dec 2009: Ran across an interesting paper by William Cook, On Understanding Data Abstraction, Revisited, which talks about the distinction between abstract data types and objects. It requires some background knowledge in places, but you might find it interesting. Plus it uses the term autognosis, which you have to admit sounds pretty cool, if somewhat opaque.

Fri, 04 Dec 2009: Lecture notes for this morning's lecture on concurrency are up. Somewhat rambly, I warn you. I tried to find a reasonable reference for concurrency online, but failed -- the field is a bit too vast. One thing you can do is look at the Wikipedia page for concurrent computing and work from there. It does describe the two kinds of concurrency I talked about (message passing, and shared memory), and lists some languages you can look at, including Erlang (a concurrent Scheme-like langauge) and Concurrent ML, from which the concurrency primitives found in PLT Scheme are derived. To get a sense of the kind of problems that occur in shared-memory concurrent programs like in Java, have a look at the following rather nice set of notes by Downey, The Little Book of Semaphores.

Fri, 04 Dec 2009: The code for this morning's lecture on concurrency is available. I've changed a little bit the Channel interface that I gave, mostly to push the block until a value you want to get is available on the channel and the block until the channel on which you want to put a value is available functionality into the channel itself as methods getOrBlock and putOrBlock. I've also put up the link to Sun's tutorial on Java concurrency. It covers a lot of what I had no time to get into, especially atomicity, which is required reading if you plan on doing anything with threads. Lecture notes and further links coming down the pipe, when I get some energy back.

Fri, 04 Dec 2009: Please find a reference implementation for the Space Game as it looks after the completion of homework 5 here.

Wed, 02 Dec 2009: Had time to kill this evening, so what better way to pass the time than make sure that your homework 6 is not completely unreasonable? So I played with a few extensions to the Space Game: a set of connected sectors of space (each a different map); commands warp to jump to other sectors, and long for long-range scans of neighboring sectors; enemies that seek orbitable artifacts to orbit when they run low on energy; and a targetting system that lets you target an artifact so that subsequent fire commands automatically find it. Here's a sample output run.

Funny thing: my strategy is to find a planet, park myself next to it, target an enemy and repeatedly fire, orbiting when I run low on energy. My new version of enemies converges to essentially the same strategy: when they run low on energy they find an orbitable artifact, recharge, and continue attacking. Basically always ends in a stalemate. I'll have to figure out a way out of the jam. Perhaps long-range weapons are affected by gravity wells?

Wed, 02 Dec 2009: Just in case this wasn't clear: feel free to change anything you want in the game for homework 6 -- if need more arguments to creators, need to change the class hierarchy, or something, knock yourself out.

Wed, 02 Dec 2009: Homework 6 is out. As I told you in class: you're allowed to work in teams (max size 2), and the official deadline is last day of classes, but I'll happily accept submissions until the day of the final exam, which is December 16th. Please pay attention to the submission instructions in the writeup, especially the part about the README.txt file.

Tomorrow night (Thursday), after everyone submits homework 5, I will post my "solutions" to that homework, so that you have a working version of Clock and autonomous enemies, etc, etc, in case you had problems.

Tue, 01 Dec 2009: Lecture notes for this morning's lecture on the MVC pattern are up. Somewhat draftier than usual -- bear that in mind.

Tue, 01 Dec 2009: The code for this morning's lecture on the MVC pattern is available. I've made a couple of changes from what I presented, in the GUI code, to be able to implement a GUIController class implementing Controller, where you can use key presses in the GUI window to control the player -- see file GUIController.java for the keys and their effect.

Tue, 01 Dec 2009: Enough of you have asked that I'm willing to grant an extension for Homework 5 -- if you get it to me by Thursday night (22h00), I'll be happy to accept it. No later though, because I plan on giving you sample solutions to that homework if you need it for Homework 6.

Tue, 01 Dec 2009: I just discovered a small error in the code I gave you for homework 5. It's not a deal breaker in any way, but the code I gave you does not quite work as I described in the writeup. In particular, the code for AutonomousEnemy reports information whether you are in god mode or not. The solution is simple: just delete method report() from AutonomousEnemy. (It was leftover from a botched cut-and-paste job.)

Mon, 30 Nov 2009: The submission page for homework 5 is now fixed.

Mon, 30 Nov 2009: There are a few problems with the submission system for homework 5 that are being dealt with right now. So please hang on if you're trying to submit -- I'll announce later when it's up and running.

Mon, 30 Nov 2009: A few more comments about homework 5, to complete what I said last week: I don't really care how or when you check for "orbitability" -- but please make sure that you write your methods orbit() and fire() with the signature I asked for in the write-up, because otherwise our testing suite will fail miserably on your code, which is never a good thing.

Mon, 30 Nov 2009: This has nothing to do with the course, but I have a coupon for a free Baby Blossom appetizer at Texas Roadhouse, good until January 30, 2010. Anybody interested, just drop me an email. First caller gets it.

Sun, 29 Nov 2009: Per request, here is the code for the observer design pattern that I demoed in class.

Tue, 24 Nov 2009: Lecture notes for this morning's lecture on the interaction of subtyping and mutation are up.

Tue, 24 Nov 2009: A comment about homework 5: Matt asks if it isn't a bit redundant to check for adjacency in both the Orbit.execute() method, and in the Ship.orbit() method. At some level, yes: presumably, if we check for adjacency in Orbit.execute(), then we don't need to check in Ship.orbit() as well, since we know we're adjacent to an orbitable artifact anyways.

My thinking here is that the Ship.orbit() method could also be invoked from a variant of an AutonomousEnemy, one that attempted to orbit artifacts, and depending on how one might end up implementing such an AutonomousEnemy checking that something is orbitable in Ship.orbit() might make sense. But mileages may vary here.

Bottom line: I don't really care where you check that something is orbitable, as long as (1) no ship can ever orbit something that is not orbitable, whether player controlled or not, and (2) the player is notified nicely when they're the one trying to do just that.

Sat, 21 Nov 2009: Homework 5 is out, a day later than I wanted it to go out. So I simplified it a bit. There is a lot of code for you to understand for this homework 5, so I would suggest you read both the write-up and the code pretty soon. Due December 1st.

Fri, 20 Nov 2009: Lecture notes for this morning's lecture on the Observer design pattern are up.

Wed, 18 Nov 2009: I'm running a bit behind finishing homework 5. It will not be done until probably tomorrow night (Thursday) or Friday. Therefore, it will be due on December 1, so you still will have a week and a half to do it.

Tue, 17 Nov 2009: Lecture notes for this morning's lecture on adapters are up, as is the code I showed in class.

Sun, 15 Nov 2009: Last Friday's lecture notes on mutations are now up.

Tue, 10 Nov 2009: This morning's lecture notes on multiple inheritance and extending ADTs is now up.

Tue, 10 Nov 2009: Small correction to the writeup of homework 4. Nothing major, just the sample output for question 3 was wrong, didn't match the specs I was asking you to implement. (That output was generated from a previous version of my sample code.)

Mon, 09 Nov 2009: Lecture notes for last Friday's lecture on inheritance and delegation are up.

Mon, 09 Nov 2009: Catching up on lecture notes. First off, notes for lecture 14 on laziness (and streams) are up. I've also added an addendum to the notes for lecture 13 on subtyping, talking about equality and overloading, and generally revisiting equality in Java. You should look at it before finishing up homework 4.

Wed, 04 Nov 2009: Homework 4 is out, due Friday November 13. See the support files in the homeworks section of the website.

Tue, 03 Nov 2009: Sorry for not being able to finish the example of sieving to obtain the stream of prime numbers during class time, but I did manage to finish five minutes after the lecture. The code is available here.

Thu, 29 Oct 2009: Graded homework 2s are slowly trickling in. I'm entering the grades on Blackboard as I receive them. If you have a grade for hw2 on Blackboard, then your graded homework will be available this afternoon in a box outside my door, from 14h00 on.

Wed, 28 Oct 2009: In case you didn't notice, or missed class on Tuesday: 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. Covers everything we've seen up to and including Tuesday's lecture.

Wed, 28 Oct 2009: Lecture notes for Tuesday's lecture on information loss, casting, and dynamic dispatch are available.

Fri, 23 Oct 2009: Lecture notes for this morning's lecture on map and reduce design patterns are available. I've also added the promised link to the the use of map and reduce at Google.

Fri, 23 Oct 2009: Lecture notes for Tuesday's lecture on polymorphism (aka generics) are available. At a whopping 18 pages, that was one dense lecture. I've also made available a fairly clear tutorial on polymorphism by Bracha, responsible for the addition of polymorphism to Java. Lecture notes for this morning should be coming up shortly; I'm revising them now.

Wed, 21 Oct 2009: Some of you asked for reference files for Artifact.java and Map.java to do homework 3 without relying on their (possibly buggy, I guess) implementation of those ADTs from homework 2. I've linked to such reference files in the homeworks section.

Sat, 17 Oct 2009: Lecture notes from last Friday on subclassing from multiple classes and interfaces are now available.

Sat, 17 Oct 2009: Slight update to homework 3, so please get the last version.

Fri, 16 Oct 2009: Lecture notes on functional iterators have been posted. And I just noticed that I forgot the lecture notes from last Friday, on interfaces. I'll remedy that over the weekend.

Fri, 16 Oct 2009: Homework 3 is out, due Tuesday October 27th.

Tue, 13 Oct 2009: Some of you probably already noticed, but there is at least one bug in the spec of homework 2. First off, the spec for the Map operation toString() on merge(m1,m2) is wrong. It should read: merge(m1,m2).toString() = m1.toString() + m2.toString(). That is, kill the space. (Think about why that is... hint: has to do with empty maps.) Also, in the tester for Map, the number of errors reported is wrong -- if you want to correct it, change Line 22 to read: totalErrors += testRandomArtifact(totalInstances);

Tue, 13 Oct 2009: Extension granted for homework 2, until Wednesday (Oct 14) at 22h00.

Tue, 13 Oct 2009: Submission instructions for homework 2 are the same as last time: go to the submission web site and put in your files. Please make sure that you send us your .java files, and not your .class files. Get in touch with our TA Jed if there are any problems.

Tue, 13 Oct 2009: Woke up sick. I'm canceling this morning's lecture. Reminder: homework 2 due tonight. I should be back online later this afternoon, if you have any questions.

Fri, 09 Oct 2009: Took longer than expected, but here is the tester for the Map ADT. I changed the default placeholder for testing merged maps to be a map with a single artifact of size 1000 by 1000. (If you're curious to see what I spent an hour trying to figure out yesterday, replace that size by the original 10 by 10 that I talked in the homework, and try to figure out why the tester slows down to a crawl. Go on, I dare you.)

Wed, 07 Oct 2009: Here we go, first typo/error in the writeup for homework 2. Question 3, the size() operation is supposed to return the size of the map. The specification for how this operation behaves for the artifact() creator is nonsensical. It should be artifact(h,w,a).size() = Coord.create(h,w). Write-up has been updated.

Tue, 06 Oct 2009: I overlooked the obvious this morning when I answered Spencer's question about the "nested subclasses" version of the implementation of the List ADT as derived from the recipe. He asked "Did I have to make the EmptyList and ConsList classes static?" The proper answer was, of course, that they have to be static because they are invoked (via their constructors) from the methods empty() and cons() in the abstract class List. Those two methods are static, so by the rule I gave you that "static methods can only refer to static things in a class", the two subclasses must be static. Thanks to the student that pointed out this answer to me at the end of class. (I forgot your name, I'm sorry about that. Can you drop me a quick email to remind me?)

Tue, 06 Oct 2009: Lecture notes for this morning's lecture have been posted below. I've also added a link to a tutorial on Java packages. Once I find a nice link on inner classes, I will add it in as well.

Mon, 05 Oct 2009: Lecture notes for Friday's lectures have been posted below.

Sat, 03 Oct 2009: Homework 2 is out. You can do questions 1 and 2 right now. Questions 3 and 4 will need to wait until Tuesday's lecture. I provided a correct implementation of Coord.java in case you do not trust yours from homework 1, and there is the skeleton of a tester for Artifact.

Sat, 03 Oct 2009: I'm running a bit behind with finishing up homework 2. I hope to get it done by later tonight. Stay tuned.

Thu, 01 Oct 2009: Our TA's office hours have been ascertained: Tuesday 15h00-17h00 in 308 WVH. Ask for Jed.

Wed, 30 Sep 2009: Lecture notes for yesterday's lecture have been posted below.

Tue, 29 Sep 2009: Down to the wire, but the submission system seems up and running. By now, you should all have received an email from our TA Jed Davis with your token to set your password on the submission server. (The email was sent to your husky.neu.edu account, so check there.) Follow the instructions in the email to set your password so you can submit your homework. Feel free to email our TA Jed if you have any questions about the submission process. Note that the submission server will send you a confirmation email after submission, and that you can submit your homework multiple times if you decide to make changes. We shall only look at the last version you submitted when grading.

Mon, 28 Sep 2009: I completely forgot to update this website with office hours, sorry about that. They're Thursdays, 16h00-18h00. My office is 328 WVH.

Mon, 28 Sep 2009: I corrected a typo in the RSS feed for the course announcement that made the feed point to the wrong address for the course web page. Unfortunately, depending on your RSS reader, this may reset the "read" markers of the posts, meaning that you may get the old posts showing up as new posts. Sorry about that.

Fri, 25 Sep 2009: Lecture notes for this morning's lecture have been posted below.

Fri, 25 Sep 2009: I've uploaded the testing program for homework 1 -- see below. Holler if there are any problems. Next up, lecture notes from this morning.

Fri, 25 Sep 2009: I've updated homework 1 to take care of something that came up in class this morning. We're now allowing zero coordinates when invoking Coord.create(). The tester I talked about this morning will be uploaded tonight. Watch this space.

Tue, 22 Sep 2009: Lecture notes for this morning's lecture have been posted below. Generally, if you find a mistake in the notes, please let me know, unless it's an obvious typo.

Tue, 22 Sep 2009: Lecture notes for last Friday's lecture have been posted below. One down, one to go.

Tue, 22 Sep 2009: Homework 1 is out, due next Tuesday, September 29th. Towards the end of the week, we will have a tester ready for you to test your code, and information about how to submit your code. Lecture notes for the last two lectures I still have to finish polishing, expect them later tonight.

Wed, 16 Sep 2009: Lecture notes for the first two lectures are up. A bit rough around the edges, but you should recognize the gist of what was discussed in class. Also, I am toying with the idea of having my office hours Thursdays 16h00-18h00. Let me know if you have issues with that. (Irrespectively of whether or not that time is the actual time I will decide on, tomorrow I will be in my office and available at that time, if you have any questions about the course.)

Mon, 07 Sep 2009: Setting up the RSS feed for the course. You should see an RSS link up in your browser.

 

Course Information

Time and Location: Tuesday/Friday 9h50-11h30 108 West Village H (#23H)

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

Office hours: Thursday 16h00-18h00 in 328 WVH

Teaching Assistants:

  • Jed Davis (Office hours: Tuesday 15h00-17h00 in 308 WVH)
  • Jonathan Hoag

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

Prerequisites: CS 2510

Textbooks: The textbook for the course is:

  • P. Sestoft, Java Precisely, 2nd edition, MIT Pess, 2005.

You may also find the following book useful, although it is not required:

  • Cay Hostermann, Object-Oriented Design and Patterns, 2nd edition, John Wiley and Sons, 2006

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.

Sep 11

Introduction

- Lecture notes

Sep 15

ADTs, algebraic specifications

- Lecture notes

Sep 18

ADT implementation in Java

- Lecture notes

Sep 22

Equality for ADTs

- Lecture notes
- Homework 1 is out

Sep 25

Software Testing

- Lecture notes

Sep 29

Errors and exceptions

- Lecture notes

Oct 2

Code reuse: subclassing

- Lecture notes
- Homework 2 is out

Oct 6

Subclassing for ADT implementations

- Lecture notes
- Java online tutorial on packages

Oct 9

Interfaces

- Lecture notes

Oct 16

Design Pattern: Functional Iterators

- Lecture notes
- Homework 3 is out

Oct 20

Polymorphism

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

Oct 23

Design Patterns: Map and Reduce

- Lecture notes
- MapReduce at Google

Oct 27

Downcasting; dynamic dispatch

- Lecture notes
- Addendum on overloading and equality

Oct 30

Midterm

 

Nov 3

Lazy structures

- Lecture notes
- Code

Nov 6

Code Reuse: Inheritance and Delegation

- Lecture notes

Nov 10

Multiple inheritance

- Lecture notes
- Java tutorial on interfaces and inheritance. Note in particular how they conflate inheritance and subclassing

Nov 13

Mutation

- Lecture notes

Nov 17

Design pattern: Adapters

- Lecture notes
- Code

Nov 20

Design pattern: Observer

- Lecture notes
- Code
- Homework 5 is out

Nov 24

Subtyping and mutation

- Lecture notes

Nov 27

Thanksgiving Break - No Classes

 

Dec 1

The Model-View-Controller Pattern

- Lecture notes
- Homework 6 is out
- Code

Dec 4

Concurrency

- Lecture notes
- Code
- Sun's tutorial on Java concurrency
- Sun's tutorial on Java sockets

Dec 8

Odds and Ends

- Lecture notes

 

Homeworks

Removed

 

Online Resources