4

We're using MySQL with Sequelize.js as the ORM.

What we're wondering is whether a DOA layer of abstraction is worthwhile. Here are our options:

  1. To use the Sequelize models throughout the application.

  2. To abstract Sequelize by building a layer that converts Sequelize models to Backbone models so that we're using Backbone throughout the rest of the application instead.

Is abstraction important in this case or is it normal to use Models from the ORM throughout the other layers?

  • What value do you get from adding the additional layer of abstraction? – Dan Pichelman Apr 5 '13 at 18:47
  • We're fairly comfortable with Backbone and it would allow us to change ORMs if needed. – Matt Apr 5 '13 at 18:48
1

Don't do it. An extra layer of hand-written code will cost you far more than you think, and return far less.

Building a DAO layer is worthwhile only if: Sequelize proves inadequate, and you can't modify Sequelize to meet your requirements, and there is another ORM that can do what you need, and the cost of building the DAO layer is less than the cost of switching your code to a new ORM.

I expect that it will cost just as much, and probably more, to create and maintain the DAO layer than you would spend later changing ORMs.

  • 2
    I think you're right about the extra effort, but I tend to disagree about not doing it because of that. I think he should build the DAO if his models don't directly map to database tables. – thelastshadow Apr 5 '13 at 20:22
  • @thelastshadow: in that case won't the Sequelize models form the DAO for the application models? – kevin cline Apr 5 '13 at 21:09
  • Downvote. Yet another example of why no one builds complex applications in nodejs. Its because nodejs devs rarely have enough tools in their belt to solve complex problems and this mentality of less is more is taken to the extreme. – Josh Woodcock Sep 19 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.