Appendix BAnswers to Exercises
Exercise 1: from Orthogonality on page 43
You are writing a class called Split
, which splits input lines into fields. Which of the following two Java class signatures is the more orthogonal design?
Answer 1: To our way of thinking, class Split2
is more orthogonal. It concentrates on its own task, splitting lines, and ignores details such as where the lines are coming from. Not only does this make the code easier to develop, but it also makes it more flexible. Split2
can split lines read from a file, generated by another routine, or passed in via the environment.
Exercise 2: from Orthogonality on page 43
Which will ...
Get The Pragmatic Programmer: From Journeyman to Master now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.