I hope this makes sense.
Let me try to restate things simply and clearly as possible.
Charles Scalfani
611

It makes sense only if the reader supplies the explanatory language that is missing.

If I now understand correctly, you are describing a situation in which a reference to an instance of an object A is passed to the constructor for a second object, B. That constructor places the reference to A into a variable private to B. Let’s call that B_ref_to_A.

The claim that this breaks encapsulation is based on the possibility that code outside of B can manipulate A. This can happen, but this does not break encapsulation. If code outside of B could change B_ref_to_A, that would break encapsulation, because B_ref_to_A is a variable private to B. But a change in A’s variables does not break encapsulation, because A’s variables are not B’s variables. If the writer of B needs the state of A to be constant, he/she would indeed need to explicitly clone A during the construction of B; otherwise, he/she would not be justified in assuming that the state of A would remain constant.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.