Continuing from the previous article.
7. Call
Calling is one of the most commonly used statements in programming, generally including system calls, self-written function calls, etc. The essence of the call is the processing of the logic module. This shows that the call is a module, which is a collection of functional statements. At the same time, this function is a logical division. It is generally impossible to divide a related statement into two functions to call.
We should pay attention to the following points about calling:
1) How to write self-written functions
2) How to call self-written functions
3) How to reference system functions
4) How to call system functions
5) When calling, pay attention to the parameter type and parameter order of the function matching the definition.
6) Pay attention to the return value of the function when calling: no value, value, and the data type of the return value
7) Pay special attention to the use of pointer parameters in self-written functions to avoid pointer overflow, causing function errors.
8) Master how to turn functions into parameters to make functions more flexible.
9) Understand the calling method of loosely coupled functions, especially master the calling and dynamic calling of webservice.
8. File operations
File operations were used very frequently in the past, but now a lot of information is stored in databases, and most of the work of file operations has been replaced by databases. However, files will still be used in background processing of data, parameter processing, output results, etc. The essence of file operations is to operate on data stored in files. Files can be used as data sources for operations or as the result of data processing.
We should pay attention to the following points regarding file operations:
1) Know the two basic types of files: binary and ASCII. The system functions opened by the two types are different. The two processing systems are different!
2) Know the types and application scope of file opening methods: read, write, read-only, write-only, etc.
3) Know the basic functions of file operations: open, close, read, write, offset pointer (positioning)
4) Know the commonly used functions for stream file operations.
5) Pay special attention to the return value of failed file operation: open failed! Write failure (file read-only, insufficient permissions, full space, etc.)
6) Understand how to handle large files (larger than 4G)
7) Due to the wide application of xls files, we must especially master the calling methods of reading, writing and other functions related to xls file processing.
8) Master the related functions of FTP, and be able to reference and call FTP.
9) How to solve the problem of starting to read or retransmit a large file before the transfer is completed.
9. Logical operations
Logical operations are generally used for logical relationships such as AND or NOT between conditional expressions. They are relatively rarely used in programs, but they often appear in applied algorithms, especially in query conditions, where AND operations are the most widely used. The essence of logical operations is the logical relationship between things. Logical operations are just the conditions and prerequisites for certain processing. It generally cannot exist alone.
Regarding logical operations, we generally need to pay attention to:
1) When multiple conditions occur, it is best to combine the conditions into two major conditions to make the program more logical and readable.
2) Understand that when an AND operation is performed, when only one condition is false, the entire expression will result in false. Instead of calculating all the conditions!
For example: the expression is a>5&&b>6&&c>7&&d>8
If a=1, the result of the expression is false, and the program will no longer evaluate b>6, c>7, d>8.
If, a=6, b=7, c=8, then the program must calculate d>8. After grasping the whole principle, we can put the condition that is most likely to be false at the front of the expression, which can improve the efficiency of the program.
In the same way, when the OR operation is performed, when only one condition is true, the entire expression is true, but not all conditions are evaluated.
3) Learn to use logical operators as parameters to dynamically generate conditional statements in queries.
4) Learn to automatically form expressions with conditions through loop statements.
For example, we look for results that are conditional on both name and gender.
Generally we can write name='Wang Hua' and sex='1'.
We can put name and sex in the fld_name array, and Wang Hua and 1 in the content array.
This conditional statement is automatically formed by operating on the array:
String exp=””;
For(int i=0;i<2;i++)
{
if(i==0)
exp=fld_name[i]+”='”+content[i]+”’”;
else
exp=exp+”&&”+ fld_name[i]+”=’”+content[i]+”’”;
}
When we have a lot of query fields, our program will be very simple and versatile.
10. Database access
Database is currently the most used technology in application software. Software without database is almost unimaginable, especially for large-scale software. The essence of a database is a quantified collection of things and their relationships. Programmers must not only master the functions of the database itself, such as database creation, table creation, index creation, and the most basic essentials of insert, update, and select usage of data manipulation languages, but also master access to the database through programs.
When accessing the database we should pay attention to:
1) How do we access the database, what is the method of accessing the database, and what parameters are required to access the database.
2) How to submit database operation commands and how to execute stored procedures.
3) How to obtain the return value of the database command and understand the meaning of the return value.
4) How to obtain the result set of the database command, how to store the result set, and how to operate the result set.
5) Learn to use table names, field names, number of fields, and number of records to perform loop operations.
6) Database operation error handling
7) Synchronization of updates to data sets and databases
8) Database transaction processing.
9) Massive data processing methods (how to use the relationship between the result set and the database to improve data processing performance, other processing methods are not discussed here)
As for some skills of the database itself, we will not discuss them here.
11. Controls
Controls are mostly used in human-computer interaction interfaces, and of course there are many functional controls that are not displayed. Controls are widely used and frequently encountered by programmers. The most commonly used ones are labels, text boxes, command buttons, list boxes, drop-down boxes, tables, etc. People operate them by dragging and dropping. The essence of control is the medium for human-machine dialogue. Of course there are also functions for reusable objects.
We generally need to pay attention to the following points when it comes to controls:
1) Pay special attention to the characteristics and usage range of each control, and learn to use the controls accurately. For example, a text box can display a string, and a label can also display a string. However, we generally use label controls to display constants and are read-only, and text boxes to display variables and are editable. After noticing these differences, we can choose our controls correctly. If we use a text box to display a title, we may be using the control inappropriately.
2) In addition to mastering dragging and dropping to give the control a position and size, we also need to master setting the properties of the control and programming the control's events. In particular, understand when each event is triggered.
3) Learn the data binding of controls, especially the binding and refresh mechanism with the database.
4) Learn how to check the validity of control input values to ensure the validity of the input data.
5) Learn how to set read-only, editable, display/non-display settings for controls.
6) Learn to reuse system controls, especially drop-down box controls. It is difficult for a general drop-down box to meet the function of displaying return codes in Chinese characters, especially in the display box where codes and Chinese characters can be input and results that meet the conditions can be displayed for users to choose. For example, you can design a drop-down box for administrative divisions. If you enter 110000 or Beijing in the box, 110000 will be returned. The ordinary drop-down box can only select among more than 3,000 administrative divisions according to the order of administrative division codes.
7) Programmers can try to design controls themselves.
8) Master the data binding method for table controls. Especially the processing methods of big data result sets.
9) Master the methods of loading various controls.
12. Class
Classes are widely used in programming, and some languages and programs are expressions of classes. For programmers, on the one hand we need to learn object-oriented programming ideas, on the other hand we need to learn to define and use classes. The essence of a class is an object-oriented abstract form. There is a lot about classes, such as encapsulation, inheritance, polymorphism and other features. However, programmers should not be confused by the rich functions of classes. They must learn the most basic things: one is to define, write and use your own classes, and the other is to learn References use system classes and other classes.
We should pay attention to the following categories:
1) Define a class, the most important thing is to define the attributes and events of the class
2) Assign values to attributes of the class
3) Programming of events
4) Class inheritance
5) Class reference
6) Class call
7) Pay special attention to the design of the entry parameters and return values of the functions in the class.
13. Parameterization
Many people are talking about parameterization and believe that parameterization can make the program more flexible and scalable. But few people know what parameterization is and what are the boundaries of parameterization? What is the method for parameter implementation?
The essence of parameterization refers to the method of solving changes in things. The important contents are: first, how to abstract things into parameters, second, how to store parameters, and third, how the program handles parameters.
For example: when opening a database, in order to adapt to changes in the database, we must abstract the username and password of the database into parameters. We can put the username and password in the config file. In the program, when opening the database, we need to obtain the username and password from the config file to form a database connection string. Open the database through this connection string.
When the username and password of the database change, we only need to change the username and password in the config file.
The above is just the simplest example of parameterization. In fact, there are many parameters in parameterization. The key depends on the programmer's vision and level.
Ordinary programmers only focus on parameterization of function parameters. In fact, functions, data structures, functional modules, and software architectures can all be parameterized, and parameter storage forms are also diverse, and parameter processing is different for everyone. Some parameters also need to consider safety.
Simple parameterization is a basic skill, but complex parameterization is an advanced skill in programming.
Many complex algorithms and architectures are mostly a combination of the above basic skills. After programmers have laid a good foundation, they can use this foundation to construct more complex algorithms and write better programs.
There is a lot of content on the basic skills of programming. Each part can be told many interesting stories and examples, and each part can be an independent chapter. However, here I can only give some ideas and give programmers an idea and method. Its purpose is to hope that programmers will pay attention to basic skills and practical skills, spend a lot of time on these skills, and lay a good foundation; it is to hope that programmers can change the status quo of only knowing how to program without asking or knowing why they program in this way. . I hope that when programmers face an algorithm, the first thing they think of is a set of basic skills, and then they choose the most appropriate basic skills for the specific implementation of the algorithm, and then use these skills to program. This method can increase programmers' emphasis on theory, develop the idea of guided programming by theory, and change spontaneous programming into conscious programming. Only in this way will the programming level of our programmers be substantially improved.