4 ms·
Matt, now I'm working only with API and I couldn't agree more with you. Last year I worked with a very big and monolithic Rails app and all the time I was wond
by tapajos 14y ago
Matt, now I'm working only with API and I couldn't agree more with you.
Last year I worked with a very big and monolithic Rails app and all the time I was wondering about move it for services but it wasn't possible.
I'm almost convinced that we can write service layers with a very consistent API and use Rails to consume it as a client. The HTML interface should be only another client.
- MatthewPhillips 14y agoWhy? HTML is just another output format for a resource. Like Json or Xml.
- mattetti 14y ago@MatthewPhillips maybe because the logic to generate JSON and HTML is very often quite different and having a tight coupling at this level might result in some serious pains later on.
- MatthewPhillips 14y agoHow are they tightly coupled? You take the same data and either run it through a Json serializer or a view renderer.
- mattetti 14y ago> You take the same data and either run it through a Json serializer or a view renderer. My experience might be different than yours, but very often my html views quickly end up needed more than 1 resource to render and now I need to fetch data just for the html templates. The same data set isn't needed when returning json or xml and the API end points exposed for data consumption are often quite different. That said, in some cases, I agree that your approach would work.
- tapajos 14y ago@MatthewPhillips, In the real world the HTML output is not like JSON or XML as you told. It is used to show data to a human and most of the time it contains a lot of elements that are not related with the resource data even if it is not representing more than a resource in the same page. The interaction with a human doesn't happen in the same way as with another system.