Binarywriter/binaryreader + three-tier architecture Summary

Source: Internet
Author: User

He looked at binarywriter/binaryreader and tried it. He was impressed by the fact that he had been studying it for several days. By the way, he made a summary:

Concept of three-tier architecture

User Interface presentation layer (USL/UI) business logic layer (BLL) data access layer (DAL)

Role of each layer

1. Data access layer: it is the operation layer for raw data (in the form of database or text files). It provides data services for the business logic layer or presentation layer.

2: business logic layer: This layer is mainly used to address specific problems. It can also be understood as a pair of operations on the data layer to process the data business logic. In a word, it is to develop game rules!

3. layer: accept parameters for users.

Why is it divided into three layers?
We use a three-tier structure to make the project structure clearer and the division of labor clearer, which is conducive to later maintenance and upgrade. It may not improve the performance, because when the subprogram module is not executed, the main program module can only be in the waiting state. This shows that dividing an application into layers will cause some loss in its execution speed. However, from the perspective of team development efficiency, we can feel a big difference.

The three-layer structure has the following advantages:
1: Improve the maintainability of the program. The layer-3 architecture has a clear hierarchy. Once a problem occurs during operation, you can quickly identify the problem and facilitate maintenance.
2: Reasonable Development: because there is no association between the three layers except the call, you only need to define the interfaces between the three layers first, then the programmer can develop in parallel, which improves the development speed.
3: Improved system security: each layer has security settings. Even if the presentation layer is broken, the security of the next layer is guaranteed.
4: Improved system scalability: The biggest advantage of the layer-3 architecture is that the changed part does not affect the overall situation when the application system is expanded. For example, to add the Oracle database function to the system, you only need to change the data layer, and the other layers remain unchanged.

The three-layer structure has the following Disadvantages:

One obvious disadvantage of the "three-tier structure" development model is that it does not run fast enough. Of course, this "execution speed" is relative to non-hierarchical applications. The "three-tier structure" development model is not applicable to systems that require too much execution speed, such as online ticket booking, online stock trading, and so on ...... It is better at systems where business rules are easy to change.

In short: No matter which development mode or method is used, there are advantages and disadvantages.

 

Binary Code 1 using system; 2 using system. collections. generic; 3 using system. text; 4 using system. io; 5 6 namespace binarytest 7 {8 class program 9 {10 static void main (string [] ARGs) 11 {12 filestream FS = write (@ "D: \ 1.txt ", "Hello"); 13 string S = read (@ "D: \ 1.txt"); 14 console. writeline (s); 15 console. readkey (); 16} 17 // Write File 18 public static filestream write (string path, string addcontent) 19 {20 using (Filestream FS = new filestream (path, filemode. openorcreate) 21 {22 FS. seek (0, seekorigin. end); 23 // write binary stream 24 binarywriter BW = new binarywriter (FS); 25 BW. write (addcontent); 26 FS. seek (0, seekorigin. begin); // move to the file header 27 return FS; 28} 29} 30 // Read File 31 public static string read (string path) 32 {33 using (filestream FS = new filestream (path, filemode. open) 34 {35 binaryreader binreader = new binaryreader (FS ); 36 stringbuilder sb = new stringbuilder (); 37 byte [] testarray = new byte [FS. length]; 38 int COUNT = binreader. read (testarray, 0, (INT) FS. length); 39 if (count! = 0) 40 {41 // reset the position in the stream to zero.42 binreader. basestream. seek (0, seekorigin. begin); 43 sb. appendline (binreader. readint32 (). tostring (); 44} 45 return sb. tostring (); 46} 47 48} 49} 50}

 

 

 

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.