2007 Exam answers

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
== Question 1 ==
 
== Question 1 ==
[26 marks for whole question] For each part (a)-(m), name the idea (or ideas)
+
[26 marks for whole question] For each part (a)-(m), name the idea (or ideas) that best match the description and briefly explain your answer. If possible, include WikiNames.
that best match the description and briefly explain your answer. If possible,
+
 
include WikiNames.
+
# [2 marks] Keep the number of fields in a class small.
* [2 marks] Keep the number of fields in a class small.
+
#: ''Answer:'' [[One key abstraction]], [[Large class smell]]
** ''Answer:'' [[One key abstraction]], [[Large class smell]]
+
# [2 marks] Methods should use most of the fields of the method’s object.
* [2 marks] Methods should use most of the fields of the method’s object.
+
#: ''Answer:'' [[Single responsibility principle]], [[One key abstraction]]
** ''Answer:'' [[Single responsibility principle]], [[One key abstraction]]
+
# [2 marks] When several methods cooperate to do a job, give them the same name.
* [2 marks] When several methods cooperate to do a job, give them the same name.
+
#: ''Answer:'' [[Recursion Introduction]]
** ''Answer:'' [[Recursion Introduction]]
+
# [2 marks] Objects should invoke methods of contained objects.
* [2 marks] Objects should invoke methods of contained objects.
+
#: ''Answer:'' [[Tell Dont Ask]], [[Beware accesses]], [[Favor composition over inheritance]]
** ''Answer:'' [[Favor composition over inheritance]]
+
# [2 marks] A CodeSmell that supports one of RielsHeuristics.
* [2 marks] A CodeSmell that supports one of RielsHeuristics.
+
#: ''Answer:'' [[Switch statement smell]] [[Avoid switch statements]] [[Large class smell]], [[supports minimize interface size]]
** ''Answer:'' [[Switch statement smwelol]]
+
# [2 marks] A pattern that conflicts with TellDontAsk.
* [2 marks] A pattern that conflicts with TellDontAsk.
+
#: ''Answer:'' [[Observer]]
** ''Answer:''
+
# [2 marks] A pattern that supports TellDontAsk.
* [2 marks] A pattern that supports TellDontAsk.
+
#: ''Answer:'' [[Factory method]]
** ''Answer:''
+
# [2 marks] A pattern that employs DoubleDispatch.
* [2 marks] A pattern that employs DoubleDispatch.
+
#: ''Answer:'' [[Visitor]]
** ''Answer:''
+
# [2 marks] A pattern based on ModelTheRealWorld.
* [2 marks] A pattern based on ModelTheRealWorld.
+
#: ''Answer:'' [[Composite]], [[Model view controller]]
** ''Answer:''
+
# [2 marks] A pattern that conflicts with one of RielsHeuristics.
* [2 marks] A pattern that conflicts with one of RielsHeuristics.
+
#: ''Answer:'' [[Avoid no-op overrides]], [[Composite]]
** ''Answer:''
+
# [2 marks] A pattern that exhibits a CodeSmell.
* [2 marks] A pattern that exhibits a CodeSmell.
+
#: ''Answer:'' [[Iterator]], [[Parrallel hieracies smell]]
** ''Answer:''
+
# [2 marks] An architectural pattern that contains a design pattern.
* [2 marks] An architectural pattern that contains a design pattern.
+
#: ''Answer:'' [[Observer]] + [[Strategy]] = [[Model view controller]]
** ''Answer:''
+
# [2 marks] A design problem that the Waterfall Process was intended to fix.
* [2 marks] A design problem that the Waterfall Process was intended to fix.
+
#: ''Answer:'' [[Big ball of mud]]
  
 
== Question 2 ==
 
== Question 2 ==
  
[10 marks] Which of RielsHeuristics can be traced back to ideas described in
+
[10 marks] Which of RielsHeuristics can be traced back to ideas described in JohnsonAndFoote1988? For each heuristic you identify, explain how it is based on the earlier idea.
JohnsonAndFoote1988? For each heuristic you identify, explain how it is based
+
on the earlier idea.
+
  
''Answer:''
+
:''Answer:''
  
 
== Question 3 ==
 
== Question 3 ==
  
[16 marks for whole question] For each of the following maxims (a)-(d) name
+
[16 marks for whole question] For each of the following maxims (a)-(d) name other maxims (as many as you can) that support it. Briefly explain each answer.
other maxims (as many as you can) that support it. Briefly explain each answer.
+
 
(a) [4 marks] ProgramToTheInterfaceNotTheImplementation.
+
# [4 marks] ProgramToTheInterfaceNotTheImplementation.
(b) [4 marks] SeparationOfConcerns.
+
#: ''Answer:''
(c) [4 marks] SoftwareReuse
+
# [4 marks] SeparationOfConcerns.
(d) [4 marks] OpenClosedPrinciple
+
#: ''Answer:''
 +
# [4 marks] SoftwareReuse
 +
#: ''Answer:''
 +
# [4 marks] OpenClosedPrinciple
 +
#: ''Answer:''
  
 
== Question 4 ==
 
== Question 4 ==
  
[8 marks for whole question] Describe a design flaw in a 427 project produced
+
[8 marks for whole question] Describe a design flaw in a 427 project produced by one of your classmates. Choose the most serious flaw you can find, clearly describe where it occurs (including where it can be found in the wiki) and support your argument, where possible, with maxims etc.
by one of your classmates. Choose the most serious flaw you can find, clearly
+
 
describe where it occurs (including where it can be found in the wiki) and support
+
:''Answer:''
your argument, where possible, with maxims etc.
+
  
 
== Question 5 ==
 
== Question 5 ==
  
[5 marks] Imagine it was your job to interview an applicant for an OO design
+
[5 marks] Imagine it was your job to interview an applicant for an OO design job. If you were allowed to ask only one question, and from the answer you had to judge whether the person was a skilled OO designer, what would you ask? Explain your reasoning.
job. If you were allowed to ask only one question, and from the answer you had
+
 
to judge whether the person was a skilled OO designer, what would you ask?
+
:''Answer:''
Explain your reasoning.
+
  
 
== Question 6 ==
 
== Question 6 ==
  
[35 marks for whole question] The following questions refer to the UML class
+
[35 marks for whole question] See [[Trains design]].
diagram in Figure 1 and explanatory notes in Figure 2. Some getters and setters
+
and other details are omitted from the diagram, but may be assumed where
+
necessary. Document any non-trivial assumptions you need to make.
+
(a) [18 marks] Find as many Gang of Four design patterns as you can in the
+
Trains design. Name each pattern and describe where and how it is used in
+
this design. Provide just enough information to make it clear how and why the
+
pattern is applied here. Note any important variations from the standard
+
pattern. There is no need to comment here on the value of the pattern (but see
+
next question).
+
(b) [17 marks] Criticise and illuminate the design. Find as many weaknesses or
+
issues as you can, and wherever possible name relevant maxims, smells,
+
refactorings, etc, to reinforce your arguments. Also explain how each problem
+
could be fixed.
+

Revision as of 02:52, 6 October 2008

Contents

Question 1

[26 marks for whole question] For each part (a)-(m), name the idea (or ideas) that best match the description and briefly explain your answer. If possible, include WikiNames.

  1. [2 marks] Keep the number of fields in a class small.
    Answer: One key abstraction, Large class smell
  2. [2 marks] Methods should use most of the fields of the method’s object.
    Answer: Single responsibility principle, One key abstraction
  3. [2 marks] When several methods cooperate to do a job, give them the same name.
    Answer: Recursion Introduction
  4. [2 marks] Objects should invoke methods of contained objects.
    Answer: Tell Dont Ask, Beware accesses, Favor composition over inheritance
  5. [2 marks] A CodeSmell that supports one of RielsHeuristics.
    Answer: Switch statement smell Avoid switch statements Large class smell, supports minimize interface size
  6. [2 marks] A pattern that conflicts with TellDontAsk.
    Answer: Observer
  7. [2 marks] A pattern that supports TellDontAsk.
    Answer: Factory method
  8. [2 marks] A pattern that employs DoubleDispatch.
    Answer: Visitor
  9. [2 marks] A pattern based on ModelTheRealWorld.
    Answer: Composite, Model view controller
  10. [2 marks] A pattern that conflicts with one of RielsHeuristics.
    Answer: Avoid no-op overrides, Composite
  11. [2 marks] A pattern that exhibits a CodeSmell.
    Answer: Iterator, Parrallel hieracies smell
  12. [2 marks] An architectural pattern that contains a design pattern.
    Answer: Observer + Strategy = Model view controller
  13. [2 marks] A design problem that the Waterfall Process was intended to fix.
    Answer: Big ball of mud

Question 2

[10 marks] Which of RielsHeuristics can be traced back to ideas described in JohnsonAndFoote1988? For each heuristic you identify, explain how it is based on the earlier idea.

Answer:

Question 3

[16 marks for whole question] For each of the following maxims (a)-(d) name other maxims (as many as you can) that support it. Briefly explain each answer.

  1. [4 marks] ProgramToTheInterfaceNotTheImplementation.
    Answer:
  2. [4 marks] SeparationOfConcerns.
    Answer:
  3. [4 marks] SoftwareReuse
    Answer:
  4. [4 marks] OpenClosedPrinciple
    Answer:

Question 4

[8 marks for whole question] Describe a design flaw in a 427 project produced by one of your classmates. Choose the most serious flaw you can find, clearly describe where it occurs (including where it can be found in the wiki) and support your argument, where possible, with maxims etc.

Answer:

Question 5

[5 marks] Imagine it was your job to interview an applicant for an OO design job. If you were allowed to ask only one question, and from the answer you had to judge whether the person was a skilled OO designer, what would you ask? Explain your reasoning.

Answer:

Question 6

[35 marks for whole question] See Trains design.

Personal tools