2005 Exam answers
(New page: == 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...) |
|||
Line 21: | Line 21: | ||
[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. | [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 == | == 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. | [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 == | == Question 4 == | ||
− | [10 marks] If the Gang of Four decided to produce a new edition of their design | + | [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? |
− | 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 | + | :''Answer:'' |
− | and its patterns, what would you tell them? | + | |
== Question 5 == | == Question 5 == | ||
− | 5. [4 marks] The wiki pages ConflictingIdeas and DesignPatternsBreakRules | + | 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. |
− | describe opposing OO design concepts. Identify and describe a conflict that has | + | |
− | not already been documented on these pages. | + | :''Answer:'' |
== Question 6 == | == Question 6 == | ||
− | 6. [18 marks] Suggest a series of refactorings (from MartinFowler1999) that you | + | 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.) |
− | would apply to the Java code of Figure 1. (Don’t just name them – explain how | + | |
− | the code would change.) | + | |
− | public | + | public class Snorkulator { |
+ | ... | ||
+ | } | ||
+ | :''Answer:'' | ||
== Question 7 == | == Question 7 == | ||
[36 marks] See [[Sorcerers design]]. | [36 marks] See [[Sorcerers design]]. |
Revision as of 04:07, 6 October 2008
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.
- [4 marks] Methods that change attribute values should be distinct from methods that merely return values.
- Answer:
- [4 marks] Methods should not directly access attributes defined by a superclass.
- Answer:
- [4 marks] Classes should be designed around their behaviour, rather than their data.
- Answer:
- [4 marks] Classes that have subclasses should not be directly instantiated.
- Answer:
- [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.