Seams - seam like a good idea ...

18 views
Skip to first unread message

ladd.james

unread,
Oct 11, 2012, 8:50:45 PM10/11/12
to mari...@googlegroups.com
I'm enjoying Maria immensely and I'm looking forward to it evolving, although it is so succinct and
neat I'm not sure what evolution it needs.

That being said, what I have done to protect myself from future changes and to give myself a
place for things 'I want' in Maria without modifying the provided sources is to make a "seam".
(http://dictionary.reference.com/browse/seam?s=t)

A seam is where I make deliberate subclasses of each provided class and then extend them
rather than depend on the provided classes in more than one place. For example, I have
this in the file ControllerSeam.js:

maria.Controller.subclass(mynamespace, 'Controller', {});

All my other project files refer to mynamespace.Controller rather than Maria directly.
Like this:

mynamespace.Controller.subclass(mynamespace, 'SearchController', {});

One thing I wanted was to track the name of a model when it is created, and the seam
is an excellent place to put that. Should I track the name of the model, maybe not but that is
another discussion.

Ah Maria. Very nice indeed.


Peter Michaux

unread,
Oct 11, 2012, 9:38:02 PM10/11/12
to mari...@googlegroups.com
On Thu, Oct 11, 2012 at 5:50 PM, ladd.james <ladd....@gmail.com> wrote:

> maria.Controller.subclass(mynamespace, 'Controller', {});
>
> All my other project files refer to mynamespace.Controller rather than Maria
> directly.
> Like this:
>
> mynamespace.Controller.subclass(mynamespace, 'SearchController', {});

I agree and I consider this a best practice. It gives a nice place to
modify the behavior of Maria for the application.

In general, I always try to alias library namespaces into my own
project's namespace for a level of detachment from the library. For
example, in one project I created a function
mynamespace.renderTemplate that used one template engine. Later I was
able to switch to Mustache simply by rewriting the
mynamespace.renderTemplate function. In the future, if I want to
switch to another templating engine, I only have to worry about
rewriting mynamespace.renderTemplate. I don't have to go around the
app looking for all the many references to Mustache. Also if the new
engine requires a bit of a shim so it is compatible with something
Mustache specific that I used then I have a natural place to build
that shim: right in mynamespace.renderTemplate.

It is a good tip, James. Thanks for writing it up.

Peter
Reply all
Reply to author
Forward
0 new messages