This week's book giveaways are in the Jython/Python and Object-Oriented programming forums. We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line! See this thread and this one for details.
Carey, that worked, somewhat in the DAO, however the formatting on the address was wrong when it populated the JTable, Still having trouble figuring out formatting. Also, the add/update office dialog no longer functions and the same type of adjustment doesn't work there. I think, though I have 17 parameters in the office constructor, it still functioned. Trying to limit that by adding a seperate Address.class, though it makes sense to me, it is beyond me in how to integrate that with the existing code.
Coming to the point mentioned earlier in the thread of many parameters in the constructor, To eliminate the possibility of assigning wrong values to the constructor because there are too many parameters you can refactor your Office class along this lines. You can either have the OfficeBuilder as a standalone class
or as the static inner class in the Office class.
And when you build your object you can write something like this
I really like your implementation of the Builder pattern, especially having all the access to the field in the builder alone. Still, there are a few improvements (or just my preferences) that I would make.
First, there's no need for a private no-arg constructor. It's not used internally and it won't be available since there is a constructor with args.
Both the Office constructor and the getOfficeBuilder() method should be private.
Next, I made the decision to use an OfficeBuilder constructor instead of a static office() method. The main reason is so the user can have mandatory fields and default values to make the created Office object in a reasonable state. I chose to make the ID field mandatory.
Your comment seems to indicate that the getters should be in the OfficeBuilder class, but I rather put them in the Office class itself, using the getOfficeBuilder() method to access the builder's fields. This hides the internal structure of the class a bit better.
You would use my Office class like this:
All things are lawful, but not all things are profitable.
I once met a man from Nantucket. He had a tiny ad
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps