Google Groups

Noir's definition of views causes confusion with traditional MVC views

Radford Smith Nov 26, 2011 7:56 PM
Posted in group: clj-noir
This was originally posted as a GitHub issue:
If we look at things from the MVC perspective, Noir's views are
actually controllers and views coupled together, a mixture of domain
and presentation logic. In contrast to other frameworks in the same
space, such as Sinatra, a view is strictly presentation code. Noir
seems to be the outlier here.

I'm not criticizing Noir's decision to couple the traditional MVC
controller and view logic. This works well for small sites, which
seems to be Noir's primary use case right now. The problem is the
simply the name. If your site grows bigger, you'll probably move
toward the MVC architecture, and you'll have to juggle the concept of
a Noir view and and MVC view during the transition. Any reference to a
view in the Noir documentation is a mental switch from what most
people already know as a view.

This raises a question: what is Noir's intended place in the world of
web frameworks? Is it like Sinatra, where you build a small site and
eventually grow out of it, or is it something you can continue to
build on top of as your site gets more complex? As the author has
mentioned in the discussion group, decoupling Noir's components is
trivial. I think large sites and frameworks could use Noir as another
layer in the onion (as someone in #clojure IRC put it), similar to
Ring's use case.

We could make this happen and still support smaller sites. The
controller and view can still be coupled by default, but these
functions should not be called views. I haven't thought about a better
name too much (actions? pages, as in defpage?), but I wanted to raise
the issue, as I think it could confuse new users, especially those
coming from traditional MVC frameworks.

Here's an example: if you prefer to put your controller logic in
separate files, you're going to get something like this in your
server.clj as of Noir 1.2.1:

(server/load-views "src/my-app/controllers/")

If you're not familiar with Noir, this is nonsense.