Search code examples
oopdesign-patterns

Choosing Design Pattern between DB and Web App


I want to choose a design pattern for the next scenario: We have one database and one web app, for certain users I want to scramble one of the columns of the database.

Currently, we think Proxy is the best match, although its not Proxy per se (because the interface is not identical)

Its basically a class with "scramble" method, which execute it only for certain users.

Would like to hear ideas, thanks!


Solution

  • I'm not sure that I entirely understand the requirement, but if you read some data structure (either a 'model' to hold the data, or a dictionary of some kind), you could use a Decorator for your data reader to scramble the data. This would enable you to keep the same interface for all users.

    In practice, though, why go to the trouble of 'scrambling' data? If there's some data that certain users aren't allowed to see, why not just zero it out, or replace strings with "[redacted]" or similar?