Midterm Exam for Advanced Object-Oriented Design and Programming | CS 635, Exams of Computer Science

Material Type: Exam; Class: ADV OBJ ORIENT DSGN PROG; Subject: Computer Science; University: San Diego State University; Term: Spring 2009;

Typology: Exams

Pre 2010

Uploaded on 03/28/2010

koofers-user-ert
koofers-user-ert 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Name __________________________________________
Answer all 9 questions. Answer essay questions as briefly as possible.
The following might be names of patterns:! Abstract Class, Adapter, Bridge, Builder, Chain of
Responsibility, Collaborator, Command, Command Processor, Composite, Decorator, Factory
Method, Flyweight, Interpreter, Iterator, Mediator, Memento, Null Object, Observer, Prototype,
Proxy, Singleton, Specification, State, Strategy, Template Method, Visitor.
1. The text claims that design patterns help overcome some common causes of redesign of a
system. What pattern would you use to handle the following issues.
A. Algorithmic dependencies.
B. Inability to alter classes conveniently.
2. Why does the Big Ball of Mud pattern suggest postponing working on architecture when
developing software?
3. Assume we have a method called trimBlanks() on the String class that removes all leading
and trailing spaces. That is it repeatedly removes the first character of the string as long as
it is a space and repeatedly removes the last character of the string as long as it is a space.
Write XUnit (where X = J, R, C#, Cpp) test(s) for the method. C++ people can assume that
all C++ strings are an instance of the String class.
4. Explain.
A. Information Hiding
B. Encapsulation
C. Abstraction
5. What are the advantages and disadvantages of the Null Object pattern.
5/14/09"CS 635 Midterm Exam"Page 1 of 2
pf2

Partial preview of the text

Download Midterm Exam for Advanced Object-Oriented Design and Programming | CS 635 and more Exams Computer Science in PDF only on Docsity!

Name __________________________________________ Answer all 9 questions. Answer essay questions as briefly as possible. The following might be names of patterns: Abstract Class, Adapter, Bridge, Builder, Chain of Responsibility, Collaborator, Command, Command Processor, Composite, Decorator, Factory Method, Flyweight, Interpreter, Iterator, Mediator, Memento, Null Object, Observer, Prototype, Proxy, Singleton, Specification, State, Strategy, Template Method, Visitor.

  1. The text claims that design patterns help overcome some common causes of redesign of a system. What pattern would you use to handle the following issues. A. Algorithmic dependencies. B. Inability to alter classes conveniently.
  2. Why does the Big Ball of Mud pattern suggest postponing working on architecture when developing software?
  3. Assume we have a method called trimBlanks() on the String class that removes all leading and trailing spaces. That is it repeatedly removes the first character of the string as long as it is a space and repeatedly removes the last character of the string as long as it is a space. Write XUnit (where X = J, R, C#, Cpp) test(s) for the method. C++ people can assume that all C++ strings are an instance of the String class.
  4. Explain. A. Information Hiding B. Encapsulation C. Abstraction
  5. What are the advantages and disadvantages of the Null Object pattern. 5/14/09 CS 635 Midterm Exam Page 1 of 2
  1. The following methods are from classes B & C that have a common superclass A. Rewrite the methods using the Template method. Show all the methods you would create and which classes they would be in. Class B Key keyFrom(HttpRequest aRequest) { if (aRequest.identifier().size() < depth() ) { if (aRequest.hasPostDataAt( "Command")) return aRequest.postDataAt("Command"); else return defaultKey(); } if (containsAction(matchingElement(aRe- quest)) { aRequest.decodeFormData(); } return matchingElement(aRequest); } Class C Key keyFrom(HttpRequest aRequest) { if (aRequest.identifier().size() < depth() ) { return defaultKey(); } return matchingElement(aRequest); }
  2. Explain one of the following types of coupling: Data Coupling, Control Coupling, Inside In- ternal Object Coupling.
  3. Explain one of the following types of cohesion: Logical, Temporal, Procedural, Communica- tion, Sequential. Give an example.
  4. Select either the Command pattern or the Decorator pattern and explain how the pattern works. 5/14/09 CS 635 Midterm Exam Page 2 of 2