2005 Exam answers

From CSSEMediaWiki
Revision as of 00:18, 8 October 2008 by Chen Qing (Talk | contribs)
Jump to: navigation, search

Contents

Question 1

[20 marks for whole question] For each of the following descriptions (a) – (e):

  • [1 mark each] Name a maxim (or pattern, code smell, etc) that captures the idea.
  • [1 mark each] Explain the rationale for this maxim (i.e. why the maxim exists).
  • [2 marks each] Comment on the validity and value of this maxim.
  1. [4 marks] Methods that change attribute values should be distinct from methods that merely return values.
    Answer: Command query separation
  2. [4 marks] Methods should not directly access attributes defined by a superclass.
    Answer:
  3. [4 marks] Classes should be designed around their behaviour, rather than their data.
    Answer:
  4. [4 marks] Classes that have subclasses should not be directly instantiated.
    Answer:
  5. [4 marks] Very badly designed software should be completely rewritten rather than progressively edited.
    Answer:

Question 2

[6 marks] Some employers believe that aesthetic issues such as style and elegance have no place in OO software design: all that matters is functionality. Is this true? Write an argument to convince a sceptical employer of your view.

Answer:

Question 3

[6 marks] Identify maxims that either conflict with or support the Law of Demeter. For each one, explain how it conflicts with / supports the Law of Demeter. Using these ideas as justification, make a recommendation for how (or whether) experienced software engineers should apply the Law of Demeter.

Answer:

Question 4

[10 marks] If the Gang of Four decided to produce a new edition of their design patterns book, (updated with UML diagrams and examples in current OO languages), and they asked for your advice on specific ways to improve the book and its patterns, what would you tell them?

Answer:

Question 5

5. [4 marks] The wiki pages ConflictingIdeas and DesignPatternsBreakRules describe opposing OO design concepts. Identify and describe a conflict that has not already been documented on these pages.

Answer:

Question 6

6. [18 marks] Suggest a series of refactorings (from MartinFowler1999) that you would apply to the Java code of Figure 1. (Don’t just name them – explain how the code would change.)

public class Snorkulator {
  ...
}
Answer:

Question 7

[36 marks] See Sorcerers design.

Personal tools