Object Oriented Design Course : Exercise 4
Exercise 4 - Theoretical Issues
Deadline June 9th, 2004 at 13:00 (the lecture's hour)
Description

C# Overview

Read this paper first, and answer the following questions:
  1. Explain features which make C# a better solution than Java for writing performance-intensive software. Explain the work-arounds in Java for those features.
  2. For each of the following sections in the paper: polymorphism, interfaces, versioning, enums - give an example of a possible mistake a programmer can make in Java, but can’t make in C# thanks to the way that feature was designed there.
  3. (10 Points Bonus Question) Some of the features that C# has and Java doesn’t have been added to Java in JDK 1.5 (currently in beta version). Some other features that Java has and C# didn’t have been added to C# in Visual Studio.NET 2005. What are these features for each language? See: http://java.sun.com/developer/technicalArticles/releases/j2se15/ and http://msdn.microsoft.com/vcsharp/default.aspx?pull=/msdnmag/issues/04/05/c20/default.aspx

Object Serialization

Read this paper and this one, and answer the following questions:
  1. What are the design considerations for declaring a class as implementing Serializable, Externalizable, or none of them? Give an example for each case.
  2. Is object serialization "shallow" - copies only the value fields of a given object - or "deep" - copies references objects recursively as well? How would you write a class that serializes and de-serializes itself using the behavior that is not the default one?
  3. Compare the Java object serialztion and with the c# one, as described in these articles. In your answer adress the issues of ease of use, efficiency (or overhead) and customization of the serialization.
The Java Serialization Specification is also recommended reading, although not required for this exercise. In particular, it covers the subjects of versioning, the stream protocol and security in more detail. It's shorter and easier to read than most formal specifications, so give it a try :-)

Weak References

Read this paper first, as well as the References API, and answer the following questions:
  1. Offer a practical use for each of the three kinds of weak references. In each example, explain why the same outcome could not have been reached by using the other kinds of references or by a strong reference.
  2. Write an implementation of the class java.util.WeakHashMap using weak references. The class should extend AbstractMap and implement Map, use an existing "regular" Map implementation as its internal data structure, but use it to hold weak instead of strong references to stored values. Call ReferenceQueue.poll() in every access to the WeakHashMap in order to manage weakly reachable objects. Implement only the default constructor, and all the public methods the existing WeakHashMap provides.
    • Don't attach any Java files, just write the code as part of the answer.
Submission Submit a zip file contains the document with your answers. The document should be called ex4.<txt|html|ps|pdf> only.
Resources