The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
I personally don't like either option. Why create two classes that duplicate the same information. I would create a property in MyFooClass to point to FooDto. Or better yet, inherent MyFooClass from FooDto.
FooDto could be final for all we care. its whole intent, purpose, life cycle, is to turn Data into JSON and vice versa. Nothing more....
mm.. I'd like the idea of justsharing my own internal status class... but that won't fly either.. plus I have been forced to take in some dependency that prevent having these internal status in shared library.. So I do need to duplicate them in contract library upon which I depend
There should never be a possibility where an object can get constructed without it being initialized properly. Making them mandatory or optional parameters to a constructor achieves that, and the compiler will find every last place where someone has initialized the object incorrectly. Not only that, it'll run very early in the development process, ensuring that the developer that just added the new parameter has all those details still fresh in their head when the bugs are found. What better unit test could you possibly hope for?
The other aspect of how you've been asked to rewrite that code is also a better practice -- you've been asked to reduce the public interface by removing the property setters. This just ensures that nobody can reach into your object and twiddle those properties after it's been constructed. If someone needs that, they can change your code, but hopefully they will evaluate whether there's a better that ensures the object can't be put in a bad state. If the object can't ever be put in a bad state, you can't have bugs because someone was sloppy.
In a recent survey, 2/3 of the lions said that they were happy to serve as King of the Forest, while another 1/9 thought it was way too much responsibility. If 14 lions gave one of these two answers, how many lions were surveyed in total?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
You just finished watching 'Couching Tiger Hidden Dragon' didn't you?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
Last Visit: 19-Feb-20 12:11 Last Update: 19-Feb-20 12:11