Serban Petrescu
I'm an IT enthusiast which graduated Computer Science at TU-CN and works full time at @msg-systems Romania.
In order to:
... the client - server style is used.
Server:
Client:
Due to the emergence of client - server applications, a new problem arose: handling the communication between the clients and the server.
HTTP is the main protocol used for internet-based applications.
It is a request-reply protocol: a client must make a request to a server, for which the server must give a response.
Limitation: the server cannot initiate contact with a client*.
*The newer SSE mechanism allows pub-sub type of communication.
Have a well-defined structure:
Have a well-defined structure, always as a reply to a request:
The request and response payloads must be served in a well-known format. The most popular formats are: HTML, JSON, XML.
In A2 you already used HTML payloads, served by the React development web server.
For transmitting structured data, usually JSON is used because of easy handling in JavaScript (JSON.parse and JSON.stringify).
For bidirectional communication between the server and the client, WebSockets may be used (among other technologies).
Usually, WebSockets are used to push events from the server (to trigger an update of the client U.I.).
REST is a style of building (web) services, usually on top of HTTP.
You define a set of resource types (e.g. students) and operations, then you map them to paths and HTTP methods.
Resources should have a predefined data model, such that the request and response payloads use a predefined structure.
Example path and method mapping for students resource:
Operation | HTTP Method | Path |
---|---|---|
Create | POST | /students |
Read | GET | /students/1 |
Update | PUT | /students/1 |
Delete | DELETE | /students/1 |
Query | GET | /students?firstName=A&lastName=B |
Usually for the query operation, most parameters are optional (so you can use just firstName or just lastName or both).
Design pattern which handles heterogeneous actions uniformly, executed by underlying "receiver" classes. Usually used when the application needs rewind, replay or undo support.
The command type indicates the action that should be carried out and the command fields hold any parameters for the action.
By Serban Petrescu
I'm an IT enthusiast which graduated Computer Science at TU-CN and works full time at @msg-systems Romania.