Future: B/S and C/S?

Source: Internet
Author: User

1. Why is B/s difficult to provide a good user interaction experience?

The header has the following major problems:

(1) stateless HTTP protocol

Windows Forms can directly exchange information through memory, but HTTP is stateless as the basic protocol for B/S architecture communication.

If we regard the browser as a guest and the Web server as a hotel, this situation will occur under the management of the HTTP protocol: no matter how many times a guest visits, web Server regards it as the first visitor. In this way, each time a guest has to bring his/her ID card for the hotel staff to "check the identity ".

The stateless HTTP Protocol makes the Web server "unrecognizable". Although this can increase the throughput of the Web server, it brings trouble to the development of application systems. Because there are often many business processing processes in the application system, which are inherently information transfer, that is, the raw data goes in from one end, and some processing should have been done when it comes out from the other end, how can we imagine the loss of information throughout the business process? As a result, sharing information between HTTP requests becomes a headache, which is the "State persistence" problem of HTTP requests. Every B/S system must solve this problem. Microsoft thought of some "tricks", such as making full use of the hidden domain of HTML web pages, and then doing some operations on the Web server, so ASP. net has a set of technologies to maintain the status of each HTTP Request: Session, Cookie, viewstate, profile, and application.

However, the problem is not completely solved. For example, in the C/S system, a common dialog box that collects user input information has information exchange between the main form and dialog box (there are two types: Mode and non-mode, the former dialog box is not closed, and the main form cannot be activated). in B/S architecture, because each browser request is independent, I don't know how to implement direct information exchange like a mode dialog box between two independent browser windows.

Ajax uses the following method to "Touch" the mode form: Combine the main form with the dialog box "into one". The dialog box is a div element in HTML, which is hidden at ordinary times, display it as needed. Microsoft's Ajax Control Toolkit even designed a control for this function. Such a trick is not uncommon in B/S development.

As you can see, many functions that can be easily implemented in C/S are charged weekly.

(2) Special runtime environment-Browser

Browser is the front-end operating environment of the B/S system, which imposes many restrictions and cannot do many things, such as direct access to hardware (such as printers ), hardware resources cannot be fully utilized. For example, new computers are all dual-core. You can use JavaScript and HTML to write a multi-thread program.ProgramTo make full use of these two "Pentium Core "?

The C/S system runs directly on the operating system and can call all functions provided by the operating system. This restriction does not exist.

(3) embarrassing Web ClientProgramming Language-- Javascript

Traditional C/S programs can use a variety of development languages, especially mainstream object-oriented languages such as C ++, Java, and C #. They are powerful and easy to use, various development tools are complete and mature.

On the contrary, the browser B/S uses the most popular programming language JavaScript, which is not only undesirable, but even a lot of programmers "hate" and regards "programming with JavaScript" as a tough task.

Let's take a look at the two major flaws in JavaScript.

First, there is a lack of clear and unified programming models.

Although JavaScript has a Java name and adopts similar syntax, it is irrelevant to the real Java. Alas, she is an ugly duckling, and she always wants to climb the swan door, but she did not expect others to buy it.

Javascript uses many objects, but it is really unconvincing to say it is object-oriented (the basic unit of object-oriented programming is class ), for example, it does not have a keyword class similar to C # and other mainstream object-oriented languages, and there are various functions everywhere, so that allCodeIt is difficult to clearly define classes. At the same time, it is not structured (the basic unit of structured programming is a function), because the browser uses stream interpretation when parsing HTML documents, as a result, some JavaScript code is placed outside the function and executed directly when parsing the HTML document, while the other part of the code is put into the function, it is run in an event-driven manner, this leads to a complicated program execution process, which is far less concise than the unified function call Programming Method in pure structured programming.

In this way, JavaScript has the characteristics of object-oriented, structured, and unstructured programming methods, but it does not have a clear and unified programming model, it is difficult to write code with clear structures and easy maintenance, but it brings a lot of confusion.

Second, another major injury to Javascript is its browser runtime environment.

Due to historical reasons, the programming models of different browsers and even different versions of the same browser are more or less different, so you have to write code to check the browser type, for example, you need to write a set of code for IE and another set for Firefox. This is really a headache.

These problems are almost inherent defects in the B/S architecture system ". People come up with a lot of tricks to solve these problems. Ajax is a promising star.
2. Hope star-Ajax

Over the past few days, I have systematically understood Microsoft's Ajax framework. I found that the complexity of this framework far exceeded my original estimation. the engineers of Microsoft's Ajax Framework Design have explored the potential of various web development technologies, it makes up for the problems mentioned above.

(1) Expansion of the Javascript language:

By providing encapsulated Ajax libraries, Microsoft has enhanced the object-oriented features of JavaScript to facilitate inheritance, interface definition, Object serialization, triggering events, reflection types, and other functions, although there is still a gap between the real object-oriented language (such as Java/C #), it is remarkable to be able to dress up ugly JavaScript.

(2) greatly improve the function of browser-side code

With the support of Ajax library and enhanced JavaScript, with the support of the browser itself, JavaScript scripts can be written in the browser to send asynchronous requests to the server for partial page refreshing, you can directly call the web service.

(3) Introduction of component-based development (CBD)

Component-based development (CBD) has long been the mainstream development method for object-oriented systems. Although SOA (service-based architecture) is a great hype, it must be as mature as the CBD, it also takes time.

For JavaScript, it is difficult to implement the CBD without SOA.

To implement the CBD, Microsoft added many features to Javascript. Based on the Microsoft Ajax library, programmers can develop three types of reusable components: none_visual component (invisible components, equivalent to some classes that provide common functions in the object-oriented system) and behavior (behavior, expanding the functions of existing Web controls) and control (Web controls with visual interface elements ).

In particular, the dozens of controls provided in Ajax Control Toolkit basically implement B/S to simulate most of the features of the C/S user interface, is a model for the application of this new programming model.

Microsoft's enhancements to the JavaScript programming model allow software engineers to finally develop Web client code using the CBD development method. I think this is an improvement.

(4) Enhanced server capabilities

To enhance the browser code capabilities, you must use the server to work together. Ajax itself is based on the programming model supported by browser and web server (Web server provides data services, and the XMLHTTPRequest object provided by browser can send asynchronous requests to Web server. when data is returned, programmers can use JavaScript to write code to dynamically update webpages ).

Through Ajax extension, Microsoft has enhanced the functions of the server-side ASP. NET Framework. Also, common functions are externalized into simple Web controls, such as the core Ajax control scriptmanager, which is used to define updatepanel of the page updatable area and to enhance the existing ASP.. Net Control is located in dozens of extender controls in the Ajax Control Toolkit (that is, controls attached to existing controls, the purpose of which is to expand new functions for existing controls ).

With these controls, developing a Web Front-End program is similar to designing a form in VB. Now, we can not only plot windows-like interfaces, but also use Ajax asynchronous requests and partial page Refresh Technology to cooperate with Web servers, windows forms can be pushed to the user experience.

No matter how many people look down on VB, the popularity of visual programming brought by VB is indeed far-reaching. Microsoft's push for JavaScript programming is also the trend of the times. This step must be taken to improve the efficiency of web development.

However, it should be pointed out that, no matter how the day after tomorrow "supplements", after all, "inherent limitations", it is still very difficult for the B/S architecture to surpass the C/S in terms of user experience.

3. Future: B/S and C/S

Due to the simplicity of management and deployment, the B/S architecture has become the first choice for many information systems today. However, users are pursuing a good user experience. To sum up, there are the following requirements:

(1) beautiful interface. B/S has advantages.

(2) convenient input. For example, many users want to input data without having to use the mouse, or use simple clicks to automatically fill in the data, which is difficult to implement in the B/S architecture, AJAX can solve this problem to some extent.

(3) lightning speed. For c/s, there are many methods to achieve fast response, but B/S is not easy. Due to browser restrictions, the client's powerful hardware resources are almost idle. In addition, the network speed is the bottleneck of the B/S architecture. Unless the bandwidth can increase rapidly, WWW is the World Wide wait.

Although C/S has a good user experience, the problem is that it is difficult to develop a distributed system that spans the entire Internet, and because the client needs to be installed, system updates and component version management have become a major problem. Unlike the B/S architecture, you only need to consider server issues. In the C/S architecture, because multiple users access the server at the same time, the call and dependency between components are complex. In terms of multi-threaded access to shared resources and transaction processing, the client and server must be considered at the same time, and the throughput is limited greatly. Therefore, C/S is mostly built in the LAN for internal use by enterprises.

At present, B/S and C/S coexist. With the wide application of B/S technologies such as Ajax, B/S has been gaining traction, however, it is impossible to completely "kill" C/S ".

What is interesting: How does a large company like Microsoft look at the future of B/S and C/S?

I am waiting for common developers and have no chance to directly talk to the top executives of Microsoft, but we can see some clues from the product development line of our company:

Microsoft does not seem to think that B/S represents the future direction of technological development. On the contrary, many of its actions are moving towards abandoning browsers.

First, Microsoft simplifies the development and deployment of C/S, and introduces the Smart Client technology, so that updates of C/S client programs can be automatically implemented without manual intervention.

Secondly, Microsoft strives to bridge the gap between B/S and C/S, and designs ASP. net, resolutely abandon ASP, which has achieved good performance, directly adopt the "visual control + event-driven" programming method similar to VB, and even call the web page "form"-web form.

Third, Microsoft may regard Ajax as a transitional technology.

Microsoft has not moved on AJAX until it finds that Google and other companies have successfully applied Ajax technology to improve the web user experience, leading to the rapid growth of Ajax. in addition to Ajax extensions, it is clear that the entire process is not active, and there are not many resources invested, which is completely different from that of Microsoft and Netscape. However, from the built-in standard configuration of Ajax extension in vs2008 and directly integrating JavaScript debugging functions into IDE, Microsoft is still facing the reality, it acknowledges that Ajax has an important position and great development potential.

In fact, my ambition to analyze Microsoft is to "unify the world", abandon the browser, and completely unify B/S and C/S.

This is clearly seen in. Net 3.0/3.5.

First, Microsoft unified DCOM with WCF ,. net remoting and other technologies mainly used for C/S, integrating many enterprise development features originally located in COM +, along with the Web Service technology mainly used for B/S architecture, unified abstraction and encapsulation of reusable WCF services. Obviously, Microsoft wants to change the information system development model from CBD to SOA (that is, in the future, the system will assemble services rather than component ).

Secondly, microsoft abandoned the very mature window desktop programming model (Win32 API + message/event-driven) and introduced a brand new WPF programming framework, one major innovation is the emergence of the XML-compliant XAML (Application Markup Language. XAML uses plain text files in XML format to describe the application interface.

We can easily compare XAML with XHTML. The browser parses the XHTML code to generate a visual web page, while the XAML is composed. net Framework virtual machine is responsible for parsing. In Vista, because Vista is directly integrated. net Framework 3.0, You can regard Vista as a super browser, it is responsible for reading the XAML to generate the user interface, and implement all its application functions.

As a result, a new programming model emerges, regardless of the B/S or C/S system, in a unified manner: read the XAML code, parse, and display the result.

In this programming model, the browser becomes a bystander and is no longer the core of the client application.

The operating platform of the new programming model is a full-featured OS, rather than a browser with limited functionality. The difference is huge. How can a browser running on an OS function be compared with the OS itself!

Now, you can easily call various functions of the Operating System by Using the OSS APIs (application programming interfaces) organized in an object-oriented manner, make full use of client hardware resources (such.. NET Framework ). The user interface is described in XAML, which unifies the Interface Layer Technology of B/S and C/S.

The most suitable runtime environment for WPF is the Vista operating system, a subset of which is now called Silverlight. It is implemented as a browser plug-in so that WPF programs can run in traditional browsers. Since both Silverlight and Vista can parse the XAML, you can now use the XAML to write only one set of interface code, which is applicable to B/S and C/S at the same time and achieve the same user experience.

Because B/S and Ajax have some inherent shortcomings, if we compare the B/S system with Ajax enhancement functions as a dancer, then, this is actually a Dancer dancing with handcuffs. Microsoft's idea is that, instead of constantly trying to reduce the weight of the shackles, why not simply abandon them?

Microsoft launched WPF and WCF, which is such an attempt.

Microsoft's development strategy is based on the analysis of the advantages and disadvantages of B/S and C/S, which is scientific, it also takes into account its own commercial interests. However, there are still many difficulties in the final implementation of this strategy, because even if it is powerful, such as Microsoft, it cannot be integrated. Microsoft's competitors are as smart as Microsoft's and technological advances are equally rapid.

It can be asserted that, due to the continuity of information system applications, within a relatively long period of time (maybe in year 35 or even five to ten years ), b/S and C/S will coexist at the same time. Due to many outstanding characteristics of B/S, the competition with C/S will prevail, and this situation will not change significantly. Although Ajax is a heavyweight weapon of B/S systems, it is very effective and has many shortcomings. I am optimistic about its future development. However, as a web developer, you should understand and apply this technology.

What is the future pattern and whether a technology has a future is determined by the individual. I think the final competition between B/S and C/S will be the result of a joint game of multiple factors. Individuals must keep pace with the times and adjust their actions and strategies in a timely manner. This is the fate of contemporary software developers.

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.