. NET development, HTML AJAX Development Architecture of my opinion BS Ajax most simplified method Knock out Request,totally oo

Source: Internet
Author: User
Tags html form ruby on rails

In. NET development, whether Ajax or webform,webpage, it is unavoidable to deal with the request this static global, can communicate remotely objects.

And for software, according to Matin Fowler object-oriented, can take advantage of the software design of the road, the object-oriented software, oo the greatest benefit is to achieve a good package and reuse.

Through encapsulation and reuse, we can achieve their own ideal software, I summed up and often said one of the words "the whole software must be all the code to write only once, and never write the second time," This sentence indicates my own pursuit of Oo, and I also continue to my writing to more elegant and easier to reuse the direction of the move forward.

And for Oo, I also summed up the second method, is about the input point of the software, that is, "the entire software should have only one input point, that is, the configuration of the minimum." While we are writing software, read the Ood aspects of the book Most people know a single duty, based on abstraction and interface, and these methods, but also only we consider the basic problem, "it is impossible to do all things at once, but you always have time to redo", from this point of view, the reconstruction of the method of practice reflects the comprehensive personal thinking.

In fact, software development, I have always felt that in this aspect of playing some clever is necessary! Be sure to find ways to be lazy-this is from the 1th I mentioned above can be seen, repeat rework who will not like, and only write once, rather than lazy, rather say at this time has reached the stage of reuse.

But write a lot of code, found that the real refactoring, rarely after the fact has been completely written after the time, is often the side of the writing side observation, in writing a class, constantly reconstruct the method of extracting it. Then each method ends up with only a few three lines left, and the smaller and clearer methods tend to be more beneficial for individuals to extract and refactor outside of this category.

Finally, I found in the Ajax of a relatively simple method, this is the focus, I personally think that this has been the refinement of HTML AJAX development to the extreme-see now the various JS architecture, whether it is the MVC angular JS or some other Dom to do some custom-made JS framework , I personally think they may be used more elegant and conducive to use, but they always appear more JS package, not to say that JS package is not good, I personally like some of the package JS components, more commonly used table,pager and so on, but in the development and transmission of data, I do not agree with their approach, I still feel that the simplest way is always to use the original HTML features.

The development method I'm using now is to encapsulate a form using the HTML form, and the items in the form, according to Ruby on Rails design and the well-known concept of "convention greater than configuration" the Golden Law, And often some of the better has been accepted by the majority of the agreement often can be issued in accordance with the unexpected role.

So in Ajax, according to the idea of decoupling, the front end and the back end is completely separate, that is, a front end, only need to provide data back-end, and the data source can be changed to a schema or programming language to achieve, these do not matter. And we all know that today's programming languages have metadata that contains data types and operations that describe things, so with reflection, we can make the Convention a real type.

Ajax, we just need to write what we want in the form, add name, and then serialize it to the backend, the backend, we will use this name convention for the property of their own entity model to reflect the realization of the automatic assignment of the entity, which also reached the knock The purpose of out request, as far as I know, now popular OO Web language, including PHP JSP C # has its own reflection mechanism, so the mechanism is the same, so that the implementation of only one input point. That is, the configuration of the name, the global no configuration, followed by the complete Oo, can be restful, can manipulate the object in various ways.

Ps:web Ajax Development, to use the HTTP handler can also, but too many methods, often there will be a lot of handler, and the Reflection method invoke methods and the use of factory after the portal to create a method that often requires too much, you have to press constraints to get a heap, And this way the total feeling is not so graceful, finally chose the webservice, although. net2.0 Ajax extension will not find ScriptService, but also only need to take the last returned XML in the string tag content, JSON has always been a JS object, and has become a standard for transmission in the web.

Summary: Direct reflection from the request to take the model, because the data is nothing more than the request form and query string two sets, through a contract name, so that only one input, complete OO entry, minimized the idea of the configuration entrance.

Add: I personally think that when the reflection value, tend to directly by the index key to fetch, and the exception of the request null throw away, this can improve some performance advantages, because the table index and full-text search is used here, the specific value of the time, especially in the indexed key value, Nature is the direct fetch of the key value faster than the cycle comparison to take. The type conversion here is to ignore this exception when converting the type to model's property Type,catch I think it would be better.

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.