Sample Final Questions
Version of December 10th, 2007
Abstraction
What are the characteristic of object-oriented programming
that help the software problem? Give examples.
What are the desirable software qualities that are helped by
object-oriented programming characteristics? Explain how they help!
Compare and contrast abstract classes versus interfaces in
Java.
Frameworks
Why do we use pre-existing software frameworks?
Describe the basic policies and structures of the following
frameworks:
- Java collections
- Java IO streams/writers
- Swing
- SAX parsers
Refactorings
Definitions
What is a refactoring? Why do we use refactorings?
Suppose we have a series of refactoring that consists
of:
- Add a new interface.
- Add a method to the interface call "doIt()".
- Add a new class with a method doIt that does some stuff
that a method "work" in the existing code does.
- Make the new class implement the interface.
- Add a constructor to the new class.
- Add a parameter of the interface to method "work" of interface
type and pass in null.
- Change the null to an instance of the new class.
- Change the code in "work" to call the "doIt" method on the
new parameter, instead of what it had before.
This series of refactorings has certain positive qualities:
- The changes are small and incremental.
- The code runs exactly as before with no changes in behavior
after every single change.
- It introduces a well-known design pattern. (What is it?)
Nonetheless the series of refactorings is deeply unsatisfactory.
Why? Give a new series of refactorings that keeps all
the good qualities of the previous series but avoids the shortcomings.
Design Patterns
Concepts
For each of the following design patterns,
give its Intent, Applicability, Structure (using UML),
and describe the roles of the participants.
- SINGLETON
- TEMPLATE METHOD
- STRATEGY
- ITERATOR
- COMPOSITE
- DECORATOR
- STATE
- FACTORY Method
- ABSTRACT FACTORY
- PROTOTYPE
- BUILDER
- COMMAND
- ADAPTER
- PROXY
Comparisons
Compare and contrast the following behavioral patterns:
- TEMPLATE METHOD
- STRATEGY
- STATE
Describe their similarities and differences.
Mention advantages and disadvantages of each.
Compare and constrast the two design patterns:
How do we distinguish them?
Compare and contrast the design patterns:
How do we distinguish them? When are their intents?
Judgement
Describe what design patterns you would use to add the following
extensions to the appointment book program:
- Reservations added remotely remain connected to the original
reservation writer. Such a reservation can only be changed or
removed by the originator (or directly on the server).
Concurrency
Definitions
Define the following terms:
- concurrent programming
- thread
- concurrency failure
- race condition
- atomicity violation
- starvation
- deadlock
- lock/mutex
- critical region
Concurrency Failures
Define safety vs. liveness.
Why do techniques that improve safety have a tendency to worsen
liveness, and vice versa?
What are the general principles used to avoid race conditions?
Name three techniques to avoid poor concurrency (deadlock and
starvation).
Why do we often need at least three separate threads for:
- User-interaction
- server socket accepts
- socket reads and writes
What goes wrong if we combine (1,2) in a single thread? (2,3)? (1,3)?
Look at the code that was done in lecture on the last week in
class. ($CLASSHOME/src/lecture11/) Identify a
synchronization problem:
- If uncorrected, what problem could result?
- How could it be corrected.
Client-Server Programming
Define/explain:
- Client-server vs. peer-to-peer computing
- push vs. pull