Description |
Design Patterns for Generic Programming
Read this paper
first; focus on sections 1, 2 and the descriptions of the
Abstract Factory, Decorator and Visitor patterns. Answer the following questions:
- For each of these three patterns, compare their
"classic" object-oriented versions with the generic versions
that the paper presents, in terms of:
- Performance
- Number of classes
- Compilation dependencies
- Amount of "glue" code the pattern requires
- Under which conditions is each of the patterns
preferable to the other? Give at least one case in which
each version is better than the other, for each of the three
patterns.
Memory Leaks in Java Code
Read
this paper first, and answer the following questions:
- Give concrete code examples of how a memory leak can be
created in Java in these cases:
- A flyweight factory that does not release unused
flyweights.
- Observer objects that are not un-registered
when they are no longer used.
- Assume that you need to debug an application with one of
the two bugs from the previous question. Which features of a
performance analysis/debugging tool are most useful for such
a task? Give examples of how they are used, from the stage
finding that a memory leak exists at all, to the stage of
finding the source code lines that cause the problem, and
verifying that the problem was fixed.
Code Generation Models
Read
this paper first, and answer the following question:
- For each of the first five presented models of code
generators, list a scenario (different than the one given in
the paper) in which using such a code generator would save
time, reduce effort or prevent errors.
- Consider code generation from UML Models, for example
the generation of Java code from UML class and sequence
diagrams. Analyze the potential benefits and drawbacks of
this approach with respect to quality, consistency,
productivity and abstraction. Under which conditions is this
approach most valuable?
Exception-Safe Generic Containers
Read this paper
first, and
answer the following questions:
- Quote: "More generally, mutator functions should not
return T objects by value". Explain why this is a
problem. State a general rule of generic class design, that
designers must follow to avoid this problem.
- Explain why the three methods of
StackImpl
are both exception-neutral and exception-safe.
|