[Reprinted] There is no B/S system in the world, only B system and S system.

Source: Internet
Author: User

Let's talk about something that seems irrelevant to the title.

With the popularity of ajax frameworks such as prototype DWR,

The server generates js Code and returns it to the client. Calling (direct call or eval) by the client seems to have become a normal practice (I don't know if it is popular ).

This method (actually a design) is understandable, but often misunderstood and applied.

(Here the so-called "error" is based on my position. Maybe more people will think that my opinion is wrong ).

Anyone who has used DWR knows that, in fact, the JS Code that DWR sends to the client does not contain complicated business logic and performance logic. It only sends some information to the client,

This information tells the client how to call the service exposed by the server. This information is essentially only some data, but only some parameters.

The web remoting implemented by DWR is just a variant of the following practice.

Code
  1. Ajax. request ("url corresponding to service", "parameters required by service", "what to do after service call ends ")


In fact, the JS passed by DWR only plays the role of "service-related url" and "service-required parameters ", "what to do after the service call ends" the role played by these parameters.

The real business logic is still included in the service of the server.

So I have said more than once that "nothing must be done in the way of DWR, but it is difficult to do it with prototype + servlet ".

Because both of them can and are doing the same thing.

However, this approach of DWR sometimes produces some bad hints: it is good for the server to generate js for the client to call.

It is even easy to confuse this approach with the event mechanism of JSF.

As a result, the information returned by ajax requests is rich and colorful. The most terrible one is that complicated HTML and JS scripts are returned.

Another terrible thing is that the client submits js scripts and the server runs them with rhnio.

(I once did such a terrible thing, but that system is especially objective, but it can be completely avoided, but it was just lazy at the time ).

In an ajax request and response, the information that the server interacts with the client should be a string (xml json sequence, etc.) used as a data carrier ).

The data will tell the other party what to do and provide necessary parameters for the other party, instead of telling the other party how to do it.

You can also pass js statements. However, these js statements must be equivalent to json statements, and any js statements with operations such as if for = should be avoided.

The practice of generating HTML on the server is really a concession to take care of the weak browser. In fact, this is completely wrong,

However, in a relatively long period of time, we will continue to make mistakes.

Of course, I am talking about ajax-related things here. JSP and tag are not in the scope of discussion,

However, I still want to add one sentence: Although I have used and developed tags a lot, I hate it very much,

It may be pleasant to use, but it is disgusting to develop. I hate all the html code generation on the server side.

This is another big topic about tag. There have been many discussions on javaeye in the past, so there will be no more nonsense here.

Okay, now I should say something related to the title (dizzy ).

Let me first ask a few questions:

When you want to integrate two systems written using j2ee and php respectively,

When you want to use some functions of the php system in a j2ee system,

When you want to transmit data from one j2ee system to another. net system,

What do you do?

Will it be abnormal to rewrite another system using java?

Will the j2ee system be rewritten with php/. net more abnormally?

Will php/. net code be generated using j2ee to let the other party run it?

No. The first thing you think of is WS, MQ, REST, and SOA .....

In fact, the server and the client are two independent systems, and they are two independent heterogeneous systems.

The relationship between them is very similar to the relationship between two large heterogeneous systems. The word "service" should be left empty.

The so-called "service" should be provided by the producer and enjoyed by the consumer.

Rather than: You tell me how to do each step, and then I will show you step by step. This is not a service, it is called "slavery ".

Any attempt to generate code at one end is inappropriate.

Because there is no B/S system in the world, there is only B system and S system.

To put it another way, if GWT is designed to generate the final html/js Code at runtime, it will be stupid. Fortunately, they are not, but they are not far from being stupid.

This article is also messy and I don't know what I want to say.



In fact, I just want to tell you (mainly new users) that we should look at the level and structure of the system from the service perspective,

Each layer only provides services to other layers and enjoys the services of others. It does not have the right to take into account the details of the services provided by others, nor should it allow others to interfere with themselves.

With this understanding, it is natural to know how to transmit data and how to decouple system hierarchies.

Of course, based on the principle that "Everything is not absolute and everything is exceptional", my views are not applicable to all systems.

The above points only represent my personal views (of course some of them are not my first). You are welcome to raise your objection.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.