Let's talk about my understanding of c/c ++.

Source: Internet
Author: User

Let's talk about my understanding of c/c ++.

/*************************************** ***************************
* This article is first published in the CWorld area of bbs.bluegem.org.
* My email: chenfei@sohu.com
* If this article is reprinted, please keep your contact information with me for convenience. Thank you!
**************************************** **************************/

First, c and c ++ are two different languages, although c ++ sometimes looks like c. Their main difference lies in the idea of programming.
C and c ++ are not completely advanced languages, and they are closely related to the platform. The "Platform" here may refer to different hardware platforms, such as x86, powerpc, spar, or 64-bit amdOpteron. It also refers to a specific software platform, which is commonly used in linux, win32, for example, a voice card or ibm MQ. Therefore, to learn c/c ++, you must grasp the knowledge of the platform, or the features of the c/c ++ language and platform-related features.

Next, let's talk about the platform-independent knowledge.
1. syntax. There is basically nothing to talk about. Be familiar with the most common problems, know where it is, and pay attention to some details, such as the result of sizeof () in different context, the form parameters and real parameters of the function, and the copy constructor of the class.
2. Standard library. Both c and c ++ provide powerful standard libraries, such as string, errno, time, and especially stl in c ++. Familiarity with the standard library can reduce our programming efforts, and the implementation of the standard library is the most efficient and stable. I think Microsoft's msdn is one of the best electronic documents.
3. Programming specifications or habits. This is a necessary condition for a qualified programmer and an important symbol of the transformation from a student programmer to a professional programmer. If you want to improve your skills in this area, you can refer to Dr. Lin's "high quality C ++ _ C Programming Guide" and "programming Cultivation, of course, the best way is to enter a formal company for formal training. In fact, there is no need to stick to the program specifications. Different units and even different projects have different requirements for the specifications, so that you can clearly write the program, the code is stable, easy to read, easy to maintain, professional, and compliant with the relevant regulations of the Organization.
4. Program engineering management. Programming standards are for individuals, while engineering management is for all programmers in charge of the project. Project management emphasizes the ability to accept management. If the tasks delivered by superiors cannot be completed as required, then ...... Second, can individuals manage their own modules very scientifically, such as project file arrangement (win32 programmers should be lucky in this regard, both vc and bcb have done a good job in project management, and most * nix programmers have to do this part by themselves), as well as functional division design of functions. These are all small-scale project management practices. Some talented and diligent programmers will gradually grow into project leaders until the cto, responsible for overall project management. There are many specific management methods, such as academic cmm. Besides, when a project reaches a certain scale, the narrow Software Engineering cannot meet the needs of project management. programmers have to resort to some management ideas and methods of traditional engineering.
5. Programming ideas. The guiding ideology of programming ideology engineering is like the great Mao Zedong Thought in the Chinese revolution. The c/c ++ programming philosophy is quite different. C emphasizes process-oriented theory, and c ++ emphasizes object-oriented theory. As the technology advances, process-oriented theories cannot meet the needs of the times. They are mainly reflected in large projects and used purely process-oriented methods for development. programmers often fall into the issue of how to implement functions already implemented by their predecessors, in particular, it is difficult to focus on the business logic when designing the gui. In addition, the Code is messy and it is difficult to implement effective maintenance and secondary development. The object-oriented theory solves this problem, but it does not mean that the process-oriented theory has been eliminated. Any object-oriented language still uses the process-oriented three axes when implementing specific functional modules: sequence, Condition Selection, and loop. From this perspective, the process orientation is not weakened, but more important than before. The core purpose of object-oriented programming is to reuse and encapsulate some of the work that is often done so that programmers can focus on business logic. Another important feature of c ++'s programming philosophy is model programming, such as stl. Note that stl is not an object-oriented product.
In fact, there are not many people who can really do a good job in process-oriented c. Even fewer people who have deep knowledge in c ++, at least I am not :(. In many cases, the program we write can only be called object-based.

Let's talk about platform-related knowledge.
1. System-level data types and APIs. Let's talk about the data type. In an old example, the int length of a 16-bit machine and a 32-bit machine is two bytes and four bytes respectively. In addition, ms defines N multiple data types based on the standard data type, which may be harmful to those who have written vc. Looking at the software source code of the linux cross-operating system platform, countless # ifdef ..... System-level APIs are generally c interfaces. win32 has sdks and directX. Typical functions include winmain () and SendMessage (). glibc in linux. Typical functions include setuid (), tmpfile ().
2. Data Types and APIs of non-General platforms. Some specific software and hardware environments also provide specific data types and APIs, such as the encryption card and the driver provided by the data transmission card; ibm mq (mq provides c and c ++ APIs ).
3. Different class libraries. Working in c ++, you must be familiar with related class libraries on different platforms, such as ms mfc. The cross-platform General Libraries include boost, I have also used an encryption/decryption algorithm library crypto ++ (crypto ++ also provides c and c ++ APIs ). Learning to reuse previous code is also a step.
Development is always performed on a specific platform, so it is necessary to be familiar with at least one system-level api or class library. You need to be familiar with some specific libraries based on the different focuses and project requirements in your work. For example, I often used some encryption and decryption algorithms, so I must be very familiar with crypto ++. In addition, familiarity with and use of some public-purpose libraries such as boost has a multiplier effect on development work.
4. Understand the process of program compilation and connection. Static links, dynamic links, and dynamic loading and unloading of databases. As the project grows, it is impossible to solve all the problems in an executable file. For programmers on the ms Platform, refer to msdn. For linux programmers, refer to advanced-linux-programming.
5. You must be familiar with at least one development debugging tool regardless of the platform you work on. Windows programmers are very happy. ms provides the integrated development environment visual c ++ (.. net), borland provides bcb. Traditional linux programmers generally use gcc and gdb. At present, there are many integrated development environments in linux, which greatly facilitates the development work.

It is unlikely that all of the above will be finished in a few days and should be gradually improved at work. At first, I focused on the syntax, norms, and standard libraries. It is best to lay a solid foundation. With the increase of work experience, the project will gradually become dominant and be responsible for some overall design work. In this case, we need to consciously use process-oriented or object-oriented theories for design and develop code specifications that comply with our own project. Before you start, think carefully about the functional modules that may be used. Is there any possibility of reusing previous code? Does the correctness and efficiency of these reusable codes meet your own requirements?
Confucius said that he would learn and don't think about it. After finishing the project, he will take a rest and adjust it for a period of time. Then, he will have a lot of experience from the design to the specific code review. I usually look at the standard library and system library. I am more familiar with public-purpose libraries, such as boost, and I am very prepared. In addition to the specific implementation technologies mentioned earlier, it is better to read some programming ideas and improve internal skills, for example, thinking in c ++ and design patterns are good learning materials.
There are many outstanding open source projects. Reading the code of these projects, finding out the bugs and communicating with the author is also an important way to improve the technical level.
In some large projects, api programming interfaces may be provided to others. The interface definition needs to be negotiated by both parties. The style should be closer to the standard library or a professional library such as mfc and boost.

This article focuses on traditional programming. With the development of the times, many new technologies, such as java and. net stands for the n-layer structure (refer to my other article "My Java Road 1"); and activX, COM, and CORBA are basically centered around the internet, the original intention is cross-platform, and the core goal is reuse. Understanding these technologies is not only a professional skill, but also a benefit to deepen the understanding of traditional programming.

 

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.