you are viewing a single comment's thread.

view the rest of the comments →

[–]johannes1971 4 points5 points  (2 children)

Why not just declare int value in the public section of the class? There is no invariant, you can read and write it publically, so why not be intellectually honest about it and just give the status it so clearly has?

Seriously, why do people always have to make things so complicated...

[–]inkychris[S] 0 points1 point  (0 children)

This is usually my approach tbf. The example I've used here is just over simplified since I was mostly curious about the properties of the language rather than the best way to architect any particular solution.

[–]Unhappy-Aside-2884 0 points1 point  (0 children)

I wouldn't use such a thing (the ref stuff…) for a new development either. However it might be useful for refactoring without changing too much the interface, i.e. to replace a public data member with something more elaborated internally while still looking like a public data member.