R
R
Roman —2016-01-14 17:05:20
API
Roman —, 2016-01-14 17:05:20

RESTful API and MVC - what is it?

Hello!
I am a beginner web developer.
SW. web developers explain what REST and RESTful API are in normal, simple language. As I understand it, this is a set of functions on the server that handle requests like GET, POST, PUT and DELETE? Or is it something more? Basically, are RESTful APIs being developed for all web servers?
MVC -> Model-View-Controller. I understand what View is all templates, Model is all database connection schemes and schemes for creating new tables and table fields in the database. But what is a Controller? Is this the entire application logic?
Are there other application architectures besides MVC? Which are more effective for the web?
Thanks.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Makarov, 2016-01-14
@helloimnewbie

The main message of using the RESTful API is to apply the basic idea of ​​the Web to the interaction of automatic agents (applications), and not just people.
The main idea of ​​the Web is to build a distributed information system by publishing some abstract resources, giving them identifiers (in today's web - hierarchical), defining a number of simple and well-known operations on them that do not depend on the content of the resource (the same GET, POST, PUT, etc.). .d.), and linking these resources with links (this is called hypermedia, and in particular, hypertext when it comes to textual information).
Just as people have been publishing information on the web for other people to consume since the advent of the Web, so RESTful web services publish hierarchically structured resources for consumption by clients. The only difference is in the presentation - for people it's plaintext/HTML, for automatic agents it's JSON/XML/other formats that are convenient to process.
Thus, if you want to publish some information as a RESTful API, you need to present it as a set of resources, and express all operations on this information through a set of predefined operations. The trick is that in many tasks these predetermined operations are quite enough, the main thing is to correctly determine the resources.
It is important to understand that a "resource" is usually some entity, a "noun". As Anton Zhukov correctly noted, the /getItems resource, although it can exist in principle, speaks of an unsuccessfully designed API (the action is presented as a resource).
There are other approaches to distributed application architecture, such as architectures based on RPC (remote procedure call). Information in such architectures is also presented as a set of entities, however, operations on them are determined by a specific task, and each entity will have its own set. This is more in line with the classical OOP approach. Thus, RESTful follows the approach of many entities (resources) - few operations (and these operations are known in advance), and RPC - few entities, but many operations on them.
Also an important feature of REST is the lack of state persisted between requests to resources. This is very important for system scaling.
The REST architecture itself is not tied to specific technologies and protocols, but in the realities of the modern Web, building a RESTful API almost always involves using HTTP and some common resource representation formats, such as JSON, or, less popular today, XML.
The point of using REST is that the principles that have shown themselves well in the "human" web and made it possible to build the largest distributed IS are also applied to the "web of machines".
The answer is long, but I have no idea how to explain it in a shorter way so as not to distort the understanding. If something is not clear - ask.

A
Anton Zhukov, 2016-01-14
@MrCheater

1. RESTful API also has recommendations for naming urls www.restapitutorial.com/lessons/restfulresourcenam...
2. There is also Model-View-ViewModel
Controller - this is what knows how to provide two-way communication between Model and View
Here is an example how urls in RESTful API should not be named:
/getItems, /setItems, /getByItemById?id=4

R
Roman, 2016-01-16
@yarosroman

Model is just a description of the data, for me, not related to any way of storing data at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question