mercredi 27 mai 2015

Design Pattern for Context-sensitive representation

Question

Is there a design pattern that allows me to create a context-sensitive representations of classes?

Definition

Representation: the available getters, and the values they return.

Context: the request context of the object.

Example

A site publishes houses for sale.

A guest user has House.getPrice(), which returns 100,000 for house X.

A registered user has House.getPrice(), which returns 95,000 for house X.

A registered user has House.getLandLordEmail(), which the guest user doesn't have.

Purpose

The practical use of this a Rest-service, to make use of automated mappings to XML/JSON with JAX-B.

Note

I'm not asking for code to implement this. I just want to know if there is a design pattern for this and what it is called.

Aucun commentaire:

Enregistrer un commentaire