Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
CoWeb assignment - 3
Object-Oriented Language Design (1 point)
In this class, we introduced a variety of object-oriented languages (Smalltalk, C++, Objective-C, Java, C#, Ruby, Eiffel, CLOS) and their language features. For each of the parts below, explain how the two approaches differ. Then, from the languages mentioned above, give one example of each case.
•Dynamic dispatch vs. static dispatch
Dynamic Dispatch = Late Binding
The process of mapping a message to code (method) at runtime
Examples: Smalltalk, Java, Objective-C, Ruby, Python
- Necessary for a dynamic system
- Dynamic typing systems have to use dynamic dispatch
Static Dispatch = Early Binding
Examples: Eiffel, C++(except virtual functions).
- Message mapping is done at compile time
- Programmer must specify enough information for this
•Single dispatch vs. multiple dispatch
Single Dispatch = Message Passing
The code that gets called is based on the type (class) of the receiver object.
- 1+2 and 1+ 2.0 both get sent to the + method inside the Integer class.
Multiple Dispatch = Generic Functions
The code that gets called is based on the type of all objects.
Prioritizes the method, rather than the object.
- 1+2 goes to a method specified for Integer plus Integer.
- 1+2.0 goes to a method specified for Integer plus Float.
Examples: Java, c++, c
•Dynamic typing vs. static typing
- Dynamic typed programming languages are those languages where variables must necessarily be defines before actually using them.This implies that dynamic typed languages do not require the explicit declaration of the variables before actually using them.
- Examples: Python.
- Static typed programming languages are those languages where variables need not be defined before actually using them. This implies that static typing has to do with the explicit declaration (or initialization) of variables before actually using them.
- Examples: JAVA, C ,C++
Garbage Collection (1 point)
Reference counting was one of the first implementations of garbage collection. Ultimately, it proved problematic. Why?
it can run in small chunks of time closely interwoven with the execution of the program. This characteristic makes it particularly suitable for real-time environments where the program can't be interrupted for very long. A cycle is two or more objects that refer to one another, which has a reference back to its parent.
Name two advantages and one disadvantage to using garbage collection.
- Ease the programmer by automating memory allocation and freeing.
- Eliminates errors that would have occurred from programmer’s mistake related to memory allocation.
- Extra work that must be done causing performance loss.
- Less control over your program.
Design Patterns (1 point)
Take one design pattern that we discussed in class and describe how it works. In your description, include a UML diagram of the pattern (these are fairly easy to find on the WWW).
The Abstraction defines the interface that the client uses for interaction with this abstraction. That is, the client makes requests directly to the Abstraction object, as that is the only interface known to the client. The Abstraction object also maintains a reference to an Implementer object. The collaboration between the objects in this pattern is such that the client requests are forwarded by the Abstraction to the Implementer through this reference. A Refined Abstraction, then, is simply any and all extensions to the Abstraction class. The Implementer defines the interface for any and all implementations of the Abstraction.
Link to this Page
- Joung-Goo Lee last edited on 27 July 2006 at 8:37 pm by c-71-56-42-67.hsd1.ga.comcast.net