View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Jack Gruendler

*waves hand* This is not the page you're looking for.

Discussion 1 currently here.

Discussion 2

Part 1: What are the differences between creational, structural, and behavioral patterns?

Creational patterns solve problems associated with creating classes and instances. For example, creational patterns can be used to control access to object creation, to modify how the object is created, or to choose the class of the object to be created at runtime. (Source: CreationalPatterns and examples)

Structural patterns deal with interfaces and composition. In other words, they illustrate ways of designing objects to build on each other to reach the goals of encapsulation and object reuse. (Source: StructuralPatterns and examples)

Behavioral patterns are concerned with program flow, or how one object passes information to another. Patterns related to event handling, message delegation, etc. fall into this category. (Source: BehavioralPatterns and examples)

Part 2: Describe an Interesting Pattern

The Strategy Pattern is a type of behavioral pattern that is useful when you want to be able to perform a certain task in multiple ways. In other words, you want to call a certain method but choose from several implementation algorithms at runtime. For example (one that I intend to use for SqueakPoint, no less!), suppose an object wants to set its layout. Instead of doing it directly, it delegates the details of the operation to a LayoutStrategy that has been assigned to it. By assigning a different subclass of LayoutStrategy, you can easily change the layout algorithm of the object. It's still accomplishing the same task (in this case, doing the layout), but it's accomplishing it in different ways (flow layout vs. box layout, etc). (Source: StrategyPattern)

Discussion 3

Part 1: In detail, describe a problem that you experienced in Squeak. What was the problem? Why did it happen? How did you eventually overcome this problem?

The biggest problem I've had using Squeak is the user interface itself. Specifically, the window management is extremely rudimentary (it's the equal of Windows 3.1 or TWM). There's no dock or taskbar or shelf, for example; instead there's only the ability to "collapse" them. Unfortunately, this is insufficent because the collapsed windows can be obscured by other ones (unlike with a dock or taskbar). There is a "layout" submenu, but I haven't successfully used it yet (for example, when I selected "table layout" all the windows (and tabs) lined up in a column, with most of them off the bottom of the screen).
Uploaded Image: windows menu.png

The Squeak Windows Menu

Switching between windows is relatively difficult, too. The only immediately obvious way is to click on the part of the target window that is showing, but that's impossible if a window is completely covered by another. There exists a Windows Menu that has such useful features as "find window," "collapse all windows," "expand all windows," "close top window," and "move top window to back;" however, it's inconvenient to access because it's a submenu of the Desktop Menu. Some of the functions do have shortcut keys, but for some reason I can't get them to work on my Mac.

These problems are exacerbated by the fact that Squeak tends to encourage having large numbers of windows. As such, it really needs good window management more than, say, a docking-pane IDE like Eclipse would. The suggested solution, "just get a bigger monitor," is a ridiculous cop-out, and is doubly so given that Squeak is supposedly written by HCI experts! Besides, a bigger monitor isn't an option anyway, in many cases. Tabbed windows, docking panes, or – the best option – Exposé would go a long way towards making the UI more usable.

As for a solution, well, I haven't really found one yet. The closest I've come is to make the Windows Menu persist (by clicking the pushpin in its upper-right corner), so I can access it's functions with a single click. However, I still can't use "collapse all windows" because it collapses the menu itself, too! I'm still looking for a way to cycle through the windows with a shortcut key, as well as being able to do so backwards. I'm also trying to figure out the trick to getting layouts to work right.

Of course, these aren't really solutions anyway, becuase a true solution would work easily and intuitively the first time, by default.

A typical cluttered Squeak desktop

Part 2: Other useful posts

The post by Jiasheng He about the Whisker Browser is really interesting. It looks as though that might be part of the solution to my window management problem! It's just too bad that it's not part of the official distribution of Squeak.

Nazli Dokuzoglu's post is useful because it provides a good overview of some of the basic methods of interaction in Squeak.

Discussion 4

Short Essays (from Spring 2001 midterm review)
  1. Explain how object-oriented programming is related to simulations

  2. A simulation is a representation of a system, and a system is a group of disparate components, interacting to accomplish a common purpose. The simulation represents the system by modeling the components and their interactions.

    Object-oriented programming is a method of creating computer simulations. "Objects" are the components of the system, and the "messages" they send to each other are the interactions. The resulting program is the simulation itself.

  3. What is a CRC card? What are they good for? When do you use them?

  4. A CRC card lists the name of a class, its responsibilities and the classes it collaborates with. CRC cards are good for object-oriented analysis, because you can model the problem just by writing cards for each candidate class and arranging them on a table. They are also useful because they're simple enough to explain to non-technical people (e.g. marketing and users).

  5. Explain in what sense inheritance is a form of delegation

  6. Inheritance is a form of delegation in that the child class its delegating its basic operations to its parent (e.g. when an object sends a message to super), and also that the parent class is delegating the the responsibility of defining some of its operations to its children classes (e.g. when something performs an action on a list of Shapes, but the actual objects are Circles or Squares or Triangles and override the action).

  7. Why is it useful to think about objects as "biological cells"? (Hint: Think about scalability and about modularity)

  8. Biological cells are similar to objects because they are instances of a well-defined class (e.g. brain cells, blood cells), they have an inheritance hierarchy (e.g. the superclass is stem cells), they have internal structures (e.g. DNA, mitochondria, etc) which are like instance variables, they perform specific functions (e.g. blood cells carry oxygen), and they can work together to compose larger structures and perform larger functions (e.g. muscle cells make up the heart, which pumps blood).

Discussion 5

Catagory: Virtual Machines and Garbage Collection

Question: Compare and contrast the following garbage collection algorithms: reference counting, mark-sweep, generation scavenging. How do they work, and what are the pros and cons of each?

Reference counting involves using a counter variable to store the number of references to an object. Each time a reference is added the counter is incremented, and each time a reference is removed the counter is decremented. If the counter reaches zero, the object is freed.


  1. It's an easy, simple algorithm.
  2. Unused objects can be indentified and freed immediately, instead of having to perform a search through the entire heap to find them.


  1. It uses extra space because it requires storing an extra integer with every object.
  2. Every time a reference is assigned to another, it has to do extra arithmetic to increment/decrement the reference counter. This can also interfere with things on the stack.
  3. Doesn't work correctly with cyclic memory references.

Mark-sweep keeps track of objects by arranging them in a tree structure, where the roots are statically-allocated or stack-allocated references, and all other objects can be found by following pointers from the roots. Instead of running incrementally as reference counting does, mark-sweep waits until the program runs out of memory. It then performs garbage collection in two phases: first, it traverses the trees, "marking" each object as it goes. Second, it "sweeps" over the entire heap, freeing everything that isn't marked and unmarking everything else in preparation for the next scan.


  1. Able to handle cyclic memory.
  2. Normal assignment incurs no overhead.


  1. Because it waits until the program runs out of memory and is a long-running algorithm, it causes the program to freeze while the garbage is collected.

Generation scavenging is a modification of mark-sweep whereby objects are classified into groups based on how old they are. The rationale for this is the generational hypothesis: the idea that the longer an object as been around, the more likely it is to continue to be used. This is because younger objects are likely to be temporary. By dividing the objects up like this, the younger objects can be garbage-collected more often than the older ones, improving efficiency.


  1. More efficient than just doing mark-sweep on the whole heap at once.


  1. Yet more stuff to keep track of.

Thoughts on Teamwork

Here's a quick list of, in our experience, what works and what doesn't regarding teamwork:

What works:

What doesn't:

Links to this Page