0

I'm preparing for front end dev interview and was reading this blog and the author mentions that MVC provides you:

Decoupled client: MVC frameworks like backbone.js incentivise you to use REST API's though their urlRoot attribute in their Models;

What does this mean? I thought decoupling means that parts of code are unaware of each other - how does using REST API's of backbone make the models unaware of other parts?

stackjlei
  • 9,485
  • 18
  • 65
  • 113
  • 1
    I believe the author means that your client side code is decoupled from your server side code and that using said frameworks encourage you to do that. – Evan Trimboli Sep 29 '16 at 00:48
  • 1
    It means they're not dependent on the specifics of each other. You can replace one REST API with another. – Barmar Sep 29 '16 at 00:48
  • can you give an example of how client side and server side is coupled? – stackjlei Sep 29 '16 at 00:50

1 Answers1

4

Decoupling is just an English word that means:

separate, disengage, or dissociate (something) from something else.

It has no specific technical relationship, but is often used in code speak to imply independence. In your REST example above, it means that the client and server are independent from each other, so that they can literally be completely swapped out, so long as they communicate along some agreed interface.

You are also correct, that it is commonly used to describe independent code.


As per your comment about coupled client/server. A coupled client/server setup simply implies that either the client and server cannot be swapped out. I think the keyword in that blog point is REST. As this is an agreed upon protocol, a third party is able to work on your project without any assumptions about the underlying interface. If you created your own communication protocol, you would consider this more coupled due to the extra information required. In other words, you would need to know more about the client in order to build a server and vice versa.

Matt Way
  • 32,319
  • 10
  • 79
  • 85
  • how can server and client be coupled? i always thought client makes xmlhttprequest and then when it gets back payload, it can do something with it. doesn't this imply that the default use case of a client and server is decoupled? – stackjlei Sep 29 '16 at 00:52
  • Elaborated on your query. – Matt Way Sep 29 '16 at 00:55