📜 ⬆️ ⬇️

“Perfect Ajax” - a new approach to building real client-server web applications

“Perfect Ajax” is a new approach to building web applications, in which the web server does not generate a single line of HTML code and interacts with the outside world only through web services; and the client interface is implemented only on the basis of client HTML, CSS, JavaScript.

The article consists of two parts. In the first part, which is more lively and provocative, I will try to interest the problem, talk about the technology “Perfect Ajax” and show its application using the example of our project “Synthesis of Knowledge Testing System” (which has some interesting features, such as using server-side JavaScript on the Mozilla Rhino platform, a prototype-oriented ORM and support for SPARQL (query language to the Semantic Web).

The second part - more boring will contain many technical details and will be released next time.
')
By a good tradition, I award with pluses all participants in the discussion, including constructive critics, with whose opinion I disagree.


Try to guess: what architecture are web applications?

To client server speak? I expected you to answer this :-)

Well, let's see. In the client-server architecture, there are:
The implementation of business logic on the server and user interaction on the client are clearly separated.

The advantages of the client-server architecture are obvious; we all know them:
  1. Business logic does not mix with user interface.
  2. You can implement several clients with different user interfaces: a command line interface, a windowed Windows interface, Flash, a web interface, a mobile interface, etc.
  3. The client computer is not resource demanding;
  4. Etc.


But, do web applications relate to client-server architecture? Web server

Indeed, in web applications there is a server responsible for the business logic of the application.

But! The client is not responsible for implementing the interface, but also the server. The server is processing the client form. The server generates the HTML code of the user interface.

Browser The client, i.e. the browser only renders the ready HTML interface code. This is, in fact, the same thing as attaching a monitor to the server and declaring this monitor as a client ...

Comment:

Here, however, there is one subtlety. Two concepts should be distinguished: web-applications and the system “browser-web-server”. Web applications run on top of the browser and web server, just like Java applications run inside the JVM, .Net applications run on the .Net Framework, and HTTP runs on top of TCP / IP.

The system “browser - web server” really has a client-server architecture: the web server accepts and processes requests, and the browser visualizes the result.

However, here we are not talking about the “browser - web server” system, but about web applications running inside it.


It is unlikely that such an approach can be called a full-fledged client-server architecture. It has many disadvantages:
  1. Mixing business logic and user interface;
  2. It is difficult to implement multiple user interfaces;
  3. Third-party programs cannot access the server (unless a special api is written);
  4. Most of the processing load of the interface falls on the server.
  5. Etc.


Mainframe However, we know in history an example of such an architecture. In the 70s, mainframes were common. A mainframe is such a huge iron chest (server) to which workstations (clients) were connected. Moreover, the workstation was just a monitor with a keyboard. And any actions of the client at the workstation were processed on the server, sometimes even such as handling keystrokes and drawing the screen [2] . Well, we know how popular mainframes are today ...

Of course, in modern web applications, part of the interface logic is implemented on the client using JavaScript. Ajax Part of the data is loaded using Ajax and visualized on the client.

But, nevertheless, many actions related to the user interface are still performed on the server. Using Ajax now in many ways even exacerbates the situation, because leads to scattering the implementation of the interface between the server and client code.

So, I propose the “Perfect Ajax” approach, which calls for the development of the Ajax idea to the logical end and to completely abandon the use of the server to implement the user interface of web applications.

The “Perfect Ajax” approach is built on the following principles:


"Perfect Ajax" in our project


I will describe this architecture on the example of our project “System of Interactive Testing of Knowledge“ Synthesis ”.

Server


In the "Ajax" concept, the server must satisfy a single condition: do not generate a single line of HTML code and communicate with the outside world via web services. In all other respects, its implementation is not limited by anything.

Here I will describe the structure of the server in our project, because it has a number of interesting features: the use of server-side JavaScript on the Mozilla Rhino platform, a prototype-oriented ORM, and the ability to use SPARQL, the query language for the Semantic Web.

However, your server implementation may be completely different and not at all like ours.


Server architecture

DBMS
DBMS
Object core of business logic
Core business logic
Prototype oriented ORM
ORM
Web-
Web-


, .

, «» web-.

.




— - JavaScript-, web-:
- -  web-

« Ajax» — .


  1. - . - « — », , , .
  2. , « », , . web- Ajax.

.


, «Ajax-» «Hivext: ».

Source: https://habr.com/ru/post/47074/


All Articles