3 ms·
A different pattern I have thought of would be to provide an accessor interface object, and certain functionality is limited to be accessible only through that
by arithma 7y ago
A different pattern I have thought of would be to provide an accessor interface object, and certain functionality is limited to be accessible only through that object. Controlling who has access to that interface can be flexible (possibly returning it along with construction, or passing it in at creation time...) Albeit, this is not without overhead, and for that, Badge is actually better, in terms of performance, if it fits the use case.
What happens when you have multiple Device objects though, in this case, they can all access VFS..
--
C++'s private inheritance can be used here to avoid some of the gymnastics, wherein, that private aspect of the class can be passed out into the appropriate party at creation time or otherwise.
To illustrate: https://gist.github.com/arithma/0d96aec5c07e2d8dc24cfc6cd31f0c16 https://gist.github.com/arithma/0d96aec5c07e2d8dc24cfc6cd31f...
Note: I have never used this in production as far as I remember.
- mmkos 7y agoPretty sure you described the attorney-client pattern.
- arithma 7y agoIf it is, it's the first time I hear about it. It always gives me a kick when I make up a similar design pattern to some grey beard's invention. Alas, I should read up on those patterns to avoid reinventing stuff and sharing things with people with appropriate names.