0

I'm confused by the "componentization" of the web UI. If I have a need for a component, should I write my own jquery-ui plugin or should I write, if I use Backbone.Marionette, a MarionetteComponent ?

Both are be reusable, isolated unit of view and behaviour. So they are conceptually fighting and compete at same level.

So I don't actually see when to create one or the other. jQuery seems to be more universal, but developers tends to write MarionetteViews/Component.

bdavidxyz
  • 2,492
  • 1
  • 20
  • 40

2 Answers2

1

If you want to use your ui component in most possible situations you could do your component without coupling with neither jquery-ui or backbone view.

If you want to make your component more future proof (yes I'm a dreamer) you can do it generic, and you can try to implement it with AMD, CommonJS or ES6 Module syntax. check for example https://medium.com/@brianleroux/es6-modules-amd-and-commonjs-c1acefbe6fc0

The advantage of this is that anyone can use it with React, Angular, [put here other future framework] or vanilla JS.

And if you want to make easier for others to implement, you can add as well the code that wraps your component to integrate with those frameworks, libraries, etc.

Fetz
  • 1,196
  • 8
  • 11
1

I am not very familiar with Backbone but as I remember this is architectural framework which should give you guidelines how to structure your code into views, controllers, components and other useful services.

On the other side there is jquery library which main purpose is to abstract the operations on the DOM so that the browser specifics can be hidden and easier interface is provided. Of course jquery has a lot more useful primitives but it doesn't say how to structure your code.

If you have decided to use Backbone you should write your components as MarioneteComponents so that they fit nicely into Backbone. Even if you write it as jquery component (or you need to use already existing component) you can create wrapper for Backbone but this is additional work.

If you want to make truly reusable component you should write it using vanilla js. After that everyone can make wrapper which will adapt it for the specific framework.

Hope this helps.

vbuhlev
  • 509
  • 2
  • 10