Campbell Ritchie wrote:What about this?I think the old version breaches the suggestion of Winston's that Strings Are Bad, and including the status in the Message object is more object‑oriented.
3. Don't complicate things prematurely.
To point #3 above, I would have suggested using a Map<Sting, String> as a start.
If your goal is just to learn how to store something for later use, then all you really need is to create a variable of the correct type in an appropriate scope, in this case, probably as an instance variable.
Simon Harrer wrote:
Regarding your other code refactoring: hm, we should have named that boolean variable "useCaptainsLog" or something like that instead. Thanks for the hint. We'll try to get that fixed in the next edition. :-)
Simon Harrer wrote:Also think about what you are doing when you quickly want to use a method or field and would like to know something about that. How often have you looked at the documentation, and how often have you really searched for the test cases? From our experience, documentation is, and will be, the first step in the search for info.
Jameson Locke wrote:My understanding of design patterns thus far is that it should not be implemented by force. Instead it should be used if your faced with a problem that suits the needs of a pattern (does that make sense?).