Is there a pattern to restrict which classes can update another class?
Posted
by
Mike
on Programmers
See other posts from Programmers
or by Mike
Published on 2013-10-25T19:20:50Z
Indexed on
2013/10/25
22:09 UTC
Read the original article
Hit count: 174
Say I have a class ImportantInfo with a public writable property Data. Many classes will read this property but only a few will ever set it. Basically, if you want to update Data you should really know what you're doing.
Is there a pattern I could use to make this explicit other than by documenting it? For example, some way to enforce that only classes that implement IUpdateImportantData can do it (this is just an example)? I'm not talking about security here, but more of a "hey, are you sure you want to do that?" kind of thing.
© Programmers or respective owner