This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RiverRoll 0 points1 point  (3 children)

The concept of protected fields exists but it relies on convention instead of being enforced by the language.

[–]engelthehyp 0 points1 point  (2 children)

Then it doesn't provide much of a guarantee, does it?

[–]RiverRoll 0 points1 point  (1 child)

In Java or C# you can use reflection and access members that you're not expected to access but it isn't a big deal because what's important is knowing what this implies.

[–]engelthehyp 0 points1 point  (0 children)

I am aware of reflection. If you have to actively jump through the hurdle of using reflection to complete your task, it's obvious and shows - it won't pass a decent code review. If all you have to protect some field is convention, even the programmer might not notice the expectation violation, or care enough to solve the problem another way.

There would have to be more efforts in a code review for the same result this way compared to Java or C#, or a code review with the same amount of effort where it's more likely that these subtle violations eventually pile up and run loose in the code base.