This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
revising the exercises from Chapter 6, page 530-531, K&B 6, I noticed that (theoretically) it should be possible to place the elements in different ways ... so in my opinion there is no absolute uniqueness concerning the solution.
Let's consider the following cases (from K&B Self Tests):
1) Try-catch-Block: it's also possible to surround with try/catch ONLY the piece of code (for example "file.createNewFile()") which really throws the exception, instead of surrounding the entire block.
2) Imports: the order of imports doesn't matter (import java.util.*; import java.text.* is the same as import java.text.* and java.util.*).
What about the real exam?
Does the order (into which I drag the elements) affect my score?
Is the "machine" lenient enough, taking into account that there might be not only one solution - provided that I use the minimum of slots?
If there are any questions requiring you to put imports in a drag and drop questions, then most likely there will be a single import to put. If indeed there are multiple imports to fill, then the order won't matter. If you are asked to put try-catch around some code, then there won't be two spots where you can put the try-catch statements. Generally there are no extra blanks which are leftover after you fill the required code, so you won't have a condition where you can put a try-catch block around a single statement or a group of statements. You'll have only enough blanks so that you can put the try-catch at one place...