Well, in my opinion, there is no good answer.
If you do this, you can be 100% certain that the return value is of type x. Otherwise, you will depend on the data level for the correct material.
I check the values, but this is mainly because I like defensive programming (anything that goes beyond malicious and should not be trusted). The domain object is beyond the scope of the display device, so you do not know what you are getting.
Next, if you make an api of some type and reuse domain objects out of scope, check the values.
The conclusion depends on the style of code that you like. This way you can implement getters and settings, or just go to the values.
Although I recommend using at least getters and setters for the case, you need to change how the handeld values are (for example, the array should become an object)
source share