1

I recently took over maintainership of a little module called Suggested Terms and received a feature request to replace the build-in queries with views.

I'm trying to weigh the pros and cons of using Views vs. a built-in query, and I don't really know whether it's worth introducing a dependency on another module, what the performance impact will be, etc.

What guidelines determine when a situation is best suited to Views, vs. using custom queries?

8
  • In my opinion, I don't think it's worth adding a dependency for this. I think it's likely to be such a niche use-case, and you could always respond by just caching the queries in the module yourself. That said, D8 obviously has Views in core, so it might be worth revisiting it for the 8.x version. At the end of the day, it's your module :-) – Chapabu Feb 25 '13 at 15:34
  • I've posted my opinion on the issue you mentioned just in case this question gets closed :-) – Chapabu Feb 25 '13 at 15:55
  • 2
    Unless someone can convince me otherwise, I think this needs to be closed; it really is non-constructive. However, I think this is an important topic, and it has come up a few times in various forms. I suggest someone start a question on meta where we can discuss how to make this a good fit for the site (and I suggest it also be a canonization request, too). – mpdonadio Feb 25 '13 at 16:18
  • Well done, another interesting question closed. – Pere Feb 25 '13 at 16:54
  • 1
    @beth It pained me to close this one. I brought a new guy on board a little while ago, and literally had this conversation with him last week. The problem isn't the facts, references, and/or specific expertise, it's the inevitable debate, arguments, and polling. I do think we can think this through on meta, though. – mpdonadio Feb 25 '13 at 22:13
1

As posted in the issue thread he's asking about caching, which Views can give you -- or as @Chapabu mentions one could cobble together yourself.

1 thing Views does give you is an ability to Alter query or presentation of results relatively easily with hook_views_pre_execute or hook_views_query_alter to tweak the standard module to make it more customizable.

I could see some merits going this route. You could also supply the default listing as a default View provided by the module. Allowing other modules to copy/override it later in code ...

1

I think that the best thing of integrating Views is that provides a standard and easy way to customize the query and look and feel of your query.

I'm not sure if this module is the right case for that (Will the users need to alter the view?), but you certainly can integrate Views in another optional submodule, called for example Suggested Terms Views (but with a better name). Depending on the usage of this new submodule, you could merge them in the future.

In my humble opinion, the Views dependency shouldn't be a problem nowadays, specially because I don't think there are many Drupal sites without Views, and at the same time with the need to use your module.

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