A discussion of the three-storey structure and the Indian model

Source: Internet
Author: User
When studying webservices, calling WebServices does not deal directly with the database. In the traditional C/s application, this kind of business layering method can be used completely. Access to the data table is generally a two-dimensional structure, so that we can build a highly reusable database reading and writing module. For example:
Function ReadData (tablename as string,sqlstring as String) as Object
...
End Function
This function returns a one-dimensional or two-dimensional recordset as an array, where one dimension array represents a record, and the two-dimensional array returns n records. SqlString is the query condition.
Function WriteData (tablename as string,recarray as Object) as Boolean
...
Rs.Open "SELECT * from Primary key =recarray (N)",...
If Rs.eof Then
Rs.addnew ' If the record does not exist, add a new record
Else
For I=0 to Rs.field.count-1
Rs.field (i) Value=recarray (i)
Next
End If
Rs.update
...
End Function
Here, for example, to add a record, the array length = number of fields. If the record exists, it is updated, or the new record is added.
The article says Indians like to use large arrays, which are actually very efficient. We set up a global array in the data query/modify module. Reads the record into an array in the Form_Load event (one-dimensional array records a record, and the two-dimensional array Records n records) so that we modify/Add the record while modifying the array. So when we refresh the display data, we just need to display the corresponding record of the array. While saving, call the above write data function to complete.
The advantage of this is that, in any case, to modify the record, we only need to perform a data-reading function, even if the data is updated, and simply select the relevant record from the array.
Adopting this kind of strict layered programming way, the programming idea is relatively simple, the code reusability is very high. It is an effective method for the design of the team cooperation concurrent programming.
Simple discussion, welcome to have similar design idea of friend criticism and discussion.




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.