Marionette model relationships - backbone.js

What's the best way to define relationships inside a Marionette/Backbone application?
I know there's Backbone-relational, but it hasn't been updated for over 6 months... Is there another way to create relationships in Backbone and/or Marionette?
Cheers!

As far as i can see the only libraries that look decent are backbone-associations and backbone-relational. In my opinion backbone associations is the best one since backbone relational hasn't been updated for a long time.

Related

Is it possible to generate Django Model from UML

is there any way to create Django Models from a given UML drawing (e.g. in diagrams.net).
Since I am still new to Django I would like to learn best practices on how to generate models in the most efficient ways.
Thanks inadvance!

Backbone js app structure

Currently am writing all my business logic inside the view class which make my view class unmanageable. Am planning to create Backbone object and move all the business logic there and invoke it from view class. Please correct me with right way of thinking
Backbone in general does not provide an entity named Controller, this is one of the reasons which Backbone called MV*. Generally user interact with views, you know well this interact means change and update over models.
"So does Backbone.js have controllers? Not really. Backbone’s views typically contain
controller logic, and routers are used to help manage application state, but neither are
true controllers according to classical MVC." (Addy Osmani Book's)
so i think your way is not incorrect, but you can improve your project structure through this solutions:
Marrionette (and also Thorax ) is a excellent framework that provide such a excellent structure for your app. You can read this annotated code and get some tip from it.
You know certainly AMD a nice api to provide modular pattern in js. Require.js a nice tool for organize your code. For more information i recommend check TodoMVC + Backbone+Require code.

Converting Regular Backbone App to use Marionette.js

I am considering changing our current application to use Marionette. The trouble is that there is currently a whole number of different views, models, and collections that have been made by other developers that use regular Backbone.
I figure I can't really convert the whole application in one go especially considering I didn't develop a whole bunch of it. I am considering just starting with the Application object and Router.
Is this going to be possible? Can I start with that and convert the actual views later?
We recently converted our backbone application to use marionette, and we started with creating a new marionette application and router, and then created a few regions and layouts which managed our older Backbone views.
We were then able to convert the old backbone views to Marionette's ItemViews and CompositeViews, and we found we were able to delete a lot of old code.
Any custom collections and models we kept untouched. You'll probably find you won't need to change them.
My advice is to have a good read through the docs and have a look through how other people have their application structured, and how their router works. There are a few boilerplate examples and generators on github.
The simple answer is yes, you can convert the app piece by piece over time.
And your strategy of starting with the Application and Router is good. I've done a few projects where I only used the Application, Router, and maybe the Module feature of Marionette, keeping the rest plain Backbone.
From the Marionette Docs:
Like Backbone itself, you're not required to use all of Marionette
just because you want to use some of it. You can pick and choose which
features you want to use. This allows you to work with other Backbone
frameworks and plugins easily. It also means that you are not required
to engage in an all-or-nothing migration to begin using Marionette.
And even once you start converting the views, you can do it one view at a time, as needed.

backbone.js marionette and co

i am a beginner in the backbonejs world und bought a book from Addy Osmani’s Backbonejs Application. i am reading the book and i try to build an application with backbonejs. Somewhere in the book, he wrote a section about backbonejs extendsion and expose how to use marionettejs. I visited on Github backbonejs extendsion site, they have many extendsion included marionettejs. Now i am confused about using backbonejs, should i use extendsion like Marionettejs too or not? I know that extendsion can brings many advantages for webdevelopment, when i gonna use backbonejs then i should use marionettejs too? When it is useful to use extendsion when not?
I find Marionette to be a useful addition to Backbone, because it reduces the amount of repetitive code you need to write (unbinding event listeners when views close, rendering one view for each item in a collection and attaching it to the DOM, etc.).
There's a nice (short) comparison of Marionette and plain Backbone here: http://addyosmani.github.io/backbone-fundamentals/#boilerplate-rendering-code
Ultimately, the best tool for you will depend on what you want to achieve and what your preferences are.
Full disclosure: I may not be entirely objective, since I'm writing a book on Marionette. But I'm sure other members will provide you with their own opinions.

What problem does backbone.js solve?

When I gloss over the backbone.js site, I'm not sure what is it trying to do.
It seems somewhat popular, but why should I want to learn it? What will it do for me? Why was it made? What problem does it solve?
I find the question perfectly valid and from my point of view there is nothing wrong with inquiring about the potential use cases of a library/toolkit.
What Backbone.js does (so do several other javascript mvc implementations) is that it provides a means of organizing the code into a modular pattern known as MVC pattern which is all about separating your code into three loosely coupled layers:
Model layer dealing purely with data and associated operations
View layer being the presentational aspects
Controller layer being the binding glue layer
(different frameworks deal with this differently : Backbone implementation of controller layer comprises of client side routing capabilities).
So, on the whole backbone provides you an infrastructure using which you can deal with data through models which contain encapsulated within them the data and associated validations, which can be observed ie. you can bind events to change events.
The View layer is mostly left for the user to separate the ui into manageable isolated sections.
Here are some problems that Backbone solves for me in the JS/HTML space:
Separation of Concerns (SoC)
Composability
Testability
Component Model
Abstraction
That is not to say that this is the ONLY system that does this. There are others. Backbone does a pretty good job of helping with these things, though.
From backbonejs.org
It's all too easy to create JavaScript applications that end up as
tangled piles of jQuery selectors and callbacks
And that's exactly what backbone does, a series of callbacks on model changes and jQuery selectors to bind events.
So to answer the question, it solves nothing only to provide a way (the backbone way) of structuring code with some slight automation in the REST side of things.

Resources