It might be difficult to read, but it is a really good book.
Carlos Reves wrote:. . . this book Effective Java (2nd Edition) by Joshua Bloch.
That may be a bit of an exaggeration. Bloch points out that factory methods have advantages, and constructors have disadvantages under some circumstances, but he doesn't actually say to prefer factory methods over constructors. At least I don't think so. In the present instance there is no need to abandon public constructors.
. . . he prefers static factory methods instead of constructors.
. . . Now, on the other hand, if you had factory methods taking ints in big‑endian and little‑endian form, that probably would justify making all your constructors private and making instances available only via factory methods. Remember that factory methods are usually static. Many Java8 classes use factory methods throughout, as you will find in this part of the Java™ Tutorials.
Thanks Knute. Appreciate!
Knute Snortum wrote:Cows for a great job fixing your code and adding to the test suite.
Ok... Didn't know that. Will take a look.
Knute Snortum wrote:A note about calling methods from constructors. Any method you call from a constructor should be marked final. This is because if the method gets overridden it could cause strange behaviors in your constructor.
I have an account on GitHub. If i upload there my code i can post the links to it here? I'm almost done for now. But already made the divide() and remainder() methods also. And added tests for them in the suite (all went well).
Knute Snortum wrote:I don't have your new add() and subtract() methods, so I'm still getting errors in them, and I don't have multiply(). Do you want to keep posting here, or are you satisfied? In a real work environment we would be posting to some sort of versioning software like git. You can do this easily with github.com for free.
You're right. I used it in an earlier version but now it's not used at all. Forgot to delete. Done...
Knute Snortum wrote:In the method validateString(), this line seem to do nothing:
I have an account on GitHub. If i upload there my code i can post the links to it here?
You can. I don't think any of the moderators have a problem with a link to GitHub, but some of them might want you to post the code directly. Still, with all the back and forth I think posting it to GitHub makes sense. Post your version of the testing program too.
I've uploaded my files to GitHub. Here is the link.
Have a Cow!
Wow! That's great! Thanks for the journal entry and for the cow!
Frits Walraven wrote:Congratulations your question has made it to our CodeRanch Journal - February 2017
Have a Cow!