1. akoha
  2. django-lean
  3. Issues
Issue #2 new

Create a facade instead of exposing models directly

Erik Wright
created an issue

See <<issue 1>>, which this is extracted from.

//Based on your example code, the experiments.util.WebUser class is used only to pass into the Experiments.test() function. From what I can tell, internal manipulation of WebUser shouldn't happen outside of the experiments app so could you change it so the request, rather than WebUser(request) gets passed into test()?//

Right now {{{test()}}} and {{{control()}}} are exposed right on the model, and the model should not know about the request. The {{{ExperimentUser}}} concept (implemented by {{{WebUser}}}) provides some decoupling between model and view.

In general I don't like the fact that users must call the models at all. There should be a facade such as {{{experiments.test()}}} that would hide the models - that would be the right place to put a function that took the experiment name and request and generated the {{{ExperimentUser}}} instance.

Comments (0)

  1. Log in to comment