News for hackers. Stuff that matters.
Re:C++ Patterns: The Badge by mindfulplay on Wednesday June 12, 2019 @12:23AM (#20161754)
I often wonder how this would map to other languages (as C++ often entails complexity and clever work arounds such as this article).

In Java or C# (and of course in C++), you could have a token system where the token can only be provided by Device :

VFS: void register(DeviceToken):

DeviceToken: empty interface (marker)

Device: private DeviceToken provideDeviceToken();

This hides both VFS and Device classes from accessing each others' private members.

You can also constrain how gets to provide DeviceToken by adding sufficient comments in code.

There are no comments on this comment yet.