[C ++OOP] (Houjie)

zhaozj2021-02-08  361

Houjie View (1/2 of the series) [C / OOP Large] "Programmer" 2001.01

About the author: Hou Jie, Taiwan computer technology writer, is a good review. Often your article is self-entertainment, quite right. Personal Website: http://jjjjhou.com http://jjjhou.readme.com.tw Beijing Mirror Station: http://expert.cbs.net/jjhou ● Open White "Programmer" magazine invites me to open a column . I have always expected a publication for programmers to make a publication of programmers as subject objects, so this invitation is difficult to push. In addition, Mr. Jiang Tao and my private hand, I will ask myself to write time for programmers as much as possible. If the column can be opened, you can not guarantee that you can not guarantee all. The mainland readers are definitely strange to me, and I will have yourself. I am a newsletter, write books, train industry personnel, hosted websites to respond to readers and students, and started lessons. Before entering the field of education, I have served as the Numerical Countries and the special researcher of the Taiwan Industrial Technology Research Institute and the special researcher, respectively, and develop CAD / CAM software and Windows multimedia systems. Some people joked that ICT Institute was Shaolin Temple, in the mountains, male and many young women, the master is like a cloud, and the grace of the mountains and the mountains are countless. At this moment, I was in the field of education for ten years. This is a road that science and technology thinks, I am also an inadvertent turn of life. However, this kind of hard research and development is also very different from the career of ivory towers, and it is really multi-color, and the interaction with readers is especially frank. My drilling field, in the previous seven years, in the Windows programming method and job system principle, in the past three years, it is placed in a more basic, and the platform-independent level. ● Books are the forever, good friends, the most interesting: I have a "no responsibility book" column in 1993, introducing some of the world's world names that I can master. Such aims and stylists have attracted a lot of attention and have created a certain first. The view and comment of "No Responsible Book Review" on the Taiwan computer publishing industry, because the goodness of the Taiwanese computer book is extremely uneven (now), the first-order, high-level anemia (now), I use programmers The comments given by the angle appear sharply. In 1998, the internet is prosperous. I move all computer prose to the online publication, scope expansion and learning attitude (but do not involve detail technology). The past book review article is also reinited. Everyone can see all these articles from the Houjie website. The reason why the book review is welcomed, on the one hand, in its knowledge, on the one hand in it's spicy. Usually my principles are only commendable books (the saying is "recommended" rather than "comment"), so the spicy flavor is only in the metapir of the Bo, or I can't hold a fire. In general, as long as there is a wealth of knowledge, rather than simply shoots the chapter, the book review column is attractive, and the spicy taste is only a branch. Zhu Jun wants to taste the true Sichuan Spicy, take a look at the book review of foreign journals, and the Chinese people who are called Wen Liang Gongqi often strokes the chest, and it is shocked. Good books are learned (especially self-revolution), and the importance is free, so the book review is always popular. A good book is a fishing rod, a good book review, let you know this fishing rod and tell you where to buy. Single book comment is good, if it can be serially, systematically, according to the evolution and level of technology, it is more valuable. In the past, I used to introduce many good books in C / OOP for Taiwan readers. As the first one of this column, I decided to summarize them, let you look at it once. ● Before reading it, I would like to talk about some bottoming words first. First, all of the following introductions are foreign books.

Dear purchase of these books may have economic pressure, but they are all famous for the famous world, I think, it is absolutely important to open this window for the reader. It is actually very convenient to buy these books, as long as you have a credit card, even the Amazon Network Bookstore (www.amazon.com) How to buy it. Our difficulties may lies in credit cards and book prices. Hey, plus shipping is really expensive. Second, when I don't even more things, I read a good book and I will not look back at the author's name. This is an absolute error attitude. How to choose a book in the book? The first time, of course, I went to the bookstore to fight against the birds, wasted a little bullet. But you can't stay in the stage where you are not more, your bullets have your bookshelf space very precious, your time is more precious. Keep in mind the name of the excellent writer, is the shortcut to find a book. This is actually a progressive character for writing the environment: so that a good writer has its own brand. Third, OO (Object-Oriented, object-oriented) field, from programming to design, OOP (ProgrmMing), OOA (Analysis), OOD (Design). At present, very mature UML (Unified Modeling Language) belongs to an NOTATION (symbolic performance method) that is used in the OO field. This article only introduces this level of OOP (only [gamma95] a little more exceptional), this is more specific, and it is more close to most programmers. Here to get abstract, get close to soft engineering or methodology. Fourth, these C / OOP books introduced will almost become a baseline that I have initially judged a person in this regard. A C programmer with years of experience, maybe you can touch the guidelines such as "always let Base Class have Virtual Destructor", but the programs of Mao, I am afraid that the Virtual Destructor is not very conceptual, let alone How to use it correctly. If he said he has seen [Meyers98], I will be more assured that his level. Interestingly, I used to have an investigation in my own class (students from the big two to graduate students). The number of students with these books is not much, and it is always the same. This makes me feel that the strongness of the strong is weak, and the tragic is. I also found that many programmers did not read books after many programmers left the school, or because they were busy, or because of the status. There are a lot of tasks, but there is no more advanced. Three or two times the tricks have been used for a long time, people are particularly volatile. Please open this window, you will find that the reason why it is huge, experts experience is reasonable. The more you read these books, you will find the value of these books and awaken some stupid behavior. Fifth, the books disconnected from the following are familiar, there are very many traditional Chinese version of the Chinese version of the Chinese version, so I am reassured and accept questions. However, the Book of Sea is vast, and the oliveth is inevitable. Sixth, for the convenience, the following is named after the labeling of academic habits. This is called in the text. Any Chinese version is particularly pleased.

[Ellis90]: The Annotated C Reference Manual, by Margaret A. Ellis and Bjarne Stroustrup, Addison-Wesley, 1990. 447 pages [Gamma95]:. Design Patterns: Elements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson, Addison-Wesley, 1995. 395 Pages Simplified Chinese version: "Design Mode", Li Yingjun, etc., Machinery Industry Press, 2000. 254 [Lippman98]: C Primer, 3rd Editoin, by Stanley Lippman And Josee Lajoie, Addison Wesley Longman, 1998. 1237 Pages. Traditional Chinese version: "C Primer Chinese", Hou Jie, Peak 1999. 1237 [Lippman96]: Inside THE C Object Model, by Stanley Lippman, Addison Wesley Longman , 1996. 280 Pages Traditional Chinese version: "Depth Exploration C Batch Model", Houjie Translation, Peak 1998. 320 [Meyers96]: More Effective C , by Scott Meyers, Addison-Wesley, 1996. 318 Pages Traditional Chinese version: "More Effective C Chinese", Houjie Translation, Pacific 2000. 318 [Meyers98]: Effective C , Second Edition, by Scott Meyers. Addison Wesley Longman, 1998. 256 Pages Traditional Chinese version: "Effective C 2 / e Chinese version "Houjie Translation, Pacific 2000. 256 [STRUOStrup97]: The C Programming Language, 3rd Editoin, by Bjarne Stroustrup, Addison WE Sley Longman, 1997. 910 Pages Traditional Chinese version: "C Program Language Classics", Leyb Bingzhe, Confucius 1999. (Not recorded) [Sutter99]: Exceptional C , by Herb Sutter, Addison Wesley Longman, 2000. 208 Pages Traditional Chinese version: "Exceptional C Chinese" Houjie Translation, Pacific 2000. 248 ● Level 1: Syntax / Language (C ) Learning Language, of course, first starting from syntax. At the beginning of the initiator, it is necessary to get in contact with the easing and else, but there is no conclusion, because the beginners have a lot of kinds, "beginners" cannot reflect their true state. There are 13 years old in my student group, and 31 years old (Of course, Of course, some people have not yet been established, some people are already experienced software engineers.

Different backgrounds, different ages, different understanding, people with different learning speeds, requires different levels of teaching materials to meet them. At different stages, the same person also requires different levels of textbooks to enhance their skills and vision. However, no matter the new generation or older (the freshman will become an older), any C programmer, I strongly recommend that there must be [Lippman98] and [STRUOSTRUP97] on your bookshelf. They are the Encyclopedia of the C grammar / language; all related issues, these two books are final arbitration, and they have considered it! They are not suitable for people who are lacking in computer basic concepts, but they are quite suitable for people with programmed experience. These two books have been tenth of the C field. The latest version is the third edition, printed with the C standard specification of 1998 case. Because the C standard specification is brought into a very large standard program, these two books have a huge change than their previous edition. If you want to take these two books to do characteristics, my personal opinion is that [lippman98] is suitable for teaching, teaching self-study test, [struostrup97] compare difficult reading, academic taste, strong test, authority The highest sex (after all Struostrup creates C ). The life of these two books is about five years. After C standard specifications, the International Standards Organization (ISO) is overview every five years, so the third edition is at least five years old. Perhaps someone thinks that as a final referee of the question, or in the C specification (published, No. ISO / IEC 14882), and the network download is only 18 US dollars, the PDF format, and the index is extremely convenient. This is of course a good tool, but this document is never suitable for learning materials, too hard. At present, there are no C compilers support complete C standard specifications, which are long, so the new language features at night are not necessarily able to exercise in your hand. With regard to Visual C , Borland C , Cygnus C three sets of performance in C standard specifications, I personally have some experience, organizing http://www.jjhou.com/qa-cpp-primer-27.txt. Why is the C compiler that is not completely supported by the standard specification? Because this is not the focus of market competition; the C development tool market has been transferred to the support of the window and a complete solution to the company. These two books are deeply instructed by tools, so index is particularly important. Two traditional version of the translation is intended to create an index (still in English terms), which can be used for the mainland. Chinese computer books have indexes, it is not common in Taiwan, and two translations are so useful for translators. Index adopts English terms, deals with a question: What should I do if I don't retain English terms? The production and supporting method of the index is a problem that technology translation is urgent. My approach is to retain the original textual or translator, and strive to maintain the Chinese and English page control, so that the original book index can be complete and easily retained. Retaining the original technique, not completely for the production of indexes, but because some words are strongly translated into Chinese, not only with industry habits, but also from the world.

This kind of practice I have taken is loved by many readers, but which original terms should be retained, which are Chinese translation, and they are all benevolence. If the translator is truly industry insiders, his choice will not be too far from the industry habits. ● Level 2: Experts (C / OOP) can learn the experience of experts while learning grammar and begin programming, but is ideal, but it is actually difficult. On the one hand, each of the quenched programming rules, the dragon dermatis may involve many knowledge, and may even relate to the underlying technology, which is overweight. On the other hand, beginners often take into account the first half of the year, and the eyes are not too high. However, if there is a good teacher, it is a kind of premium to the premium. In any case, in order to enhance your own OOP skills, expert experience is a short-term shortcut, let you learn the master's ten years of skill. [Meyers96] and [Meyers98] are the two expert experiences recommended by my very recommended. The following trials were taken in the book, and Zhu Jun could ignore his own pounds. See how much it is usually practiced. The following is taken from [Meyers98]: Terms 1: Try to replace CONST and Inline #define Terms 2: Try to replace

Terms 3: Try to replace Malloc () and Free () with New and Delete

Terms 5: Use the same type of New and Delete

Terms 6: Remember to deal with DELETE in DELETE Pointer MEMBER

Terms 7: Pre-prepared for the insufficient memory of memory

Terms 8: When writing Operator New and Operator Delete, you should pursue usual behavior

Terms 9: Avoid obscuring a formal pattern of NEW

Terms 10: If you write Operator New, please write an Operator Delete

Terpsis 11: Classes If you dynamically configure your memory, please declare a Copy Constructionor and an Assignment Operator.

Terms 12: Try to replace assignment action in the constructor

Terms 13: Members Initialization List The order should be the same as its declaration within the Class

Terms 14: Always let Base Class have Virtual Destructor

Terms 15: Let Operator = Remove * this Reference

Terms 16: Assign all Data MEMBERs in Operator =.

Terms 17: Check if you assign yourself to yourself in Operator =

Terms 19: Differences between MEMBER FUNCTIONS, NON-Member functions and Friend Functions

Terms 20: Avoid adding Data Members in the open interface

Terms 21: Use const as possible

Terms 22: Try to use Pass-by-reference (attern), use less pass-by-value (pass value)

Terms 23: When you have to pass an Object, don't try back a Reference.

Terms 29: Avoid returning internal information Handles

Terpsis 30: Avoid writing "Back Non-Const Pointers or References" and pointing to the MEMBERS of the lower access level "31: Do not return to the" Reference "of the Local object within the function", or Is the "refer to the indicator obtained in the" NEW ".

Terms 32: Delay the appearance of variable definitions as possible

Terms 33: Wisely use inlining

Terms 34: Reduce Compilation Dependencies to the lowest

Terms 35: Determine your public inheritance molding "ISA" relationship

Terms 36: Distinguish "Interface Inheritance" and "IMPLEMentation Inheritance"

Terms 37: Never redefine a inherited non-virtual funeral

Terms 38: Never redefine a preset value of inheritance

Terms 39: Avoid doing Cast Down (downward transformation) action in the inheritance system

Terms 40: Mold the relationship between Has-a or Is-Implement-In-Terms-of through Layering (Terminal Technology)

Terms 41: Distinguish inheritance and Templates

Terms 42: Wisely use private inheritance (private inheritance)

Terms 43: Multiple Inheritance, MI is wisely

Terms 45: Know the C (compiler) Sack for us to do and call which functions

Terms 47: Before using non-local static objects, make sure it already has initial values.

Terms 49: Try to get yourself with C standard programs

The following is taken from [Meyers96]:

Terms 1: Carefully distinguish Pointers and References 009

Terms 2: It is best to use C transition operations 012

Terms 3: Never deal with arrays in Polymorphically (multi-model) mode

Terms 4: Non-Necessary Do Not Use Default Constructor

Terms 5: Keep alert to the customized type conversion

Terms 6: Differences (prefix) and postfix types from Increment / Decrement operator

Terms 7: Don't load multi-load &&, ||, and operator

Terms 8: Understand New and Delete of Various Significance

Terms 9: Use DESTRUCTORS to avoid loss of resources

Terms 10: Blocking Resource Leaks in Constructors

Terms 11: Prohibiting Exceptions Flowing out of Destructors

Terms 12: Learn about the difference between "Dropping an Exception" and "Passing a Number" or "Call a Virtual Funition"

Terms 13: Capturing Exceptions in by Reference

Terms 15: Understand the cost of exceptance handling

Terms 17: Consider using Lazy Evaluation Terms 18: Staging stalls are expected to calculate

Terms 19: Understand the source of temporary objects

Terms 20: Assist in completing the "Biochemical Optimization (RVO)"

Terms 21: Using Multi-Loading Technology (OverLoad) to avoid implicit type conversion

Terms 22: Consider replacing its single type (OP) in composite forms (op =) of the operator

Terms 24: Understand Virtual Functions, Multiple Inheritance, Virtual Base Classes,

The cost required for Runtime Type Identification

Terms 25: Virtualization of Constructor and Non-Member Functions

Terms 26: Limit the number of items that can be generated by a Class

Terms 27: Requirements (or prohibited) objects are produced in HEAP

Terms 28: Smart Pointers (Elf Indicators)

Terms 29: Reference Counting (用)

Terms 30: Proxy Classes (avatar class, proxy)

Terms 31: Let the function determine how virtualization based on more than one item type

Terms 33: Designed Non-Leaf Classes as abstract categories (Abstract Classes)

[Meyers96] and [Meyers98] These two books have been famous for a long time, gain a great reputation. The following praises can make you know more about the nature and value of these two books: ◆ Before you start to start the first real C project, you should read this book; after you get some practical experience, you should read it again. . - Comp.lang.c ◆ The author does not only provide the clear rules that you should follow when you write C code, and also provide in-depth explanation and examples. - Sun Expert ◆ Each C programmer should not only have this book, and should be used to use this book. The Chinese characters are very easy to take practical use, and the cross-examination test and the index work is very good. - Computer Language ◆ This is the trick to help us help us use C . Every C program desk should have this book. In the overall quality of the C program, Scott Meyers is a great contribution to any people in the industry. - Jesse Liberty, C Report [Sutter99] is another expert experience. The author is edited by the C Report Journal, and hosts the C special program named a GURU of The Week, Gotw on the Internet. Taking his background and experience, it is naturally more fierce. This book organizes 47 clauses, because the terms are unable to express some specific guidelines, so I don't list this. This book is mainly divided into eight major items: 1. Emperive program design and C standard program library 2. Exception-saFETY topics and related technologies 3. Design and inheritance of Class 4. Compiler firewall (firewalls ) And PIMPL usual method 5. Name query, namespace, interface principles 6. Memory management 7. Trap, easy to make mistakes and harmful practices 8. Miscellaneous topics Scott Meyers written by this book, point this book Characteristics: "From the characteristics of language to components within the standard program, then to programming technology, this book jumps between different topics, always makes you lose balance, always make you have to pay full attention . ... I doubled the Gotw as "gotcha" (meaning "this can be caught you"), perhaps it is appropriate. When I took the (my) answer of the book and the answer of Sutter, I fell into the trap of his (and C ) - Although I didn't want to admit it. I can almost see Herb smile and gently say "Gotcha!" For every mistake I made. ... When you choose C as a tool, you have to think about what you are doing. C is a powerful language that helps solve the problem of effort, which makes you have to face your knowledge as you must face the language itself, program library, and program usual methods to temper your knowledge. "As far as my English is, [SUTTER99] reads without [Meyers96] and [Meyers98], the reason is that there is a lot of piligers, speaking, allusions. For example, what is Morphy Law, do you know? (Moffee Law said: Will be wrong, will be wrong.) Machiavelli also mean again? (Italian politicians, known for scams.) This kind of expert experience, mostly thin, but it is worthy of value.

Good news is, [Meyers96] and [Meyers98] have been assembled as e-books, rendered in CD, using any browser that support Java (in order to perform full-text search). How much is it? Please go to Amazon. ● Hierarchical three: underlying mechanism (C Object Model) If a special function such as Virtual Functions, Constructors, Destructors, there may be a special function of Virtual Functions, Constructors, Destructors, may have access to the internal mechanism. Don't think that it is such a deep technology, you will get caught, more you get more. Many people, including myself, just after traveling the primary mechanism, only consciousness and accept C . The so-called underlying mechanism is mainly referred to (1) Object's memory layout: Where is the DATA MEMBERS distribution? How is Static? Where is the MEMBER FUNCTIONS distribution? How is Virtual? How is it inherited? (2) Why is constructors and destructors to be evoked? (3) What is the TEMPLATE template mechanism? (4) What is the THIS indicator? (5) How is Runtime Type Identification (RTTI) I know these underlying mechanisms, you can have an impact on every action in C programs. Learn these underlying technologies, not to develop a compiler, but to completely master the C language; the learning of the underlying technology, just the process, not the target. This situation is very similar to the situation of "deep-in-depth MFC" (Hou Jie, Songgang 1997), tens of thousands of readers are not to develop Framework and read the book on MFC, which is to completely master the MFC application. A line of words in the program. The idea of ​​the underlying mechanism is very rare. I have only seen two, one is [Ellis90], one is [lippman96]. The former is nicknamed as ARM (with an annotated manual), which is the actual compilation of the early C compiler, but because of the era, I would rather recommend the latter. [Lippman96] There are a lot of incorrect, I have corrected at least more than 100 in the process of this book. Understand the essence of the transaction, is there any necessary? This problem is too simple: if you have to go so, you can accept the characteristics of the transaction, then you need it. If you are born is an Oo Wizard, or the first language you get in touch is OO language, so that everything you may think is for granted, you can completely accept the use of various characteristics, then the underlying mechanism does not need . I personally do the first line to face a lot of learners, I have to say, I have to say, understand the essence of affairs, and have an extremely faceful. help. At this point, I like to quote a sentence in Lin Yutang in the book of "Zhumen": "I only use the same thing, I don't understand its truth, it is really not high.

● Hierarchical 4: Design concepts (C / Patterns) software engineering all the efforts, nothing more than a good reuse (Reusibility). From Early Subroutines, Procedures, Functions, to later Classes, Templates. In order to the same goal. Now we have been able to encapsulate "information, and handling the operation", and can even draw the data type, and even further open the data ontology and processing materials. The respective development and can also effect (note) by some kind of "adhesive". Note: This is the spirit of the so-called generic programming. I will introduce this theme for you next month. very good. But we have never been able to inherit the design concept in a normalized manner. In the face of data structures, we just say that Stack, Queue, List, don't have to say, the smell will know that Stack is advanced, Queue is advanced first, List is a one-way or bidirectional string. In the face of Algorithms, we just say that Quick-Sort and Binary-Search don't have to say, the desperateness immediately knows that its complexity is O (n log n) and o (log n), and how the behavior mode how is it. But when we want to ensure that a Class has only one Object in the entire system? How to design when we want to have an object (or agent) to control the access to the present (in addition to the deducational evaluation lazy-evataration)? How to design when we want to walk through a certain range of a certain range in a certain method without exposing the underlying structure of the object? How to design when we want to handle basic elements in the system (such as basic characters in large documents) in a shared manner. If these are repeatedly used in large quantities, and the prematured people are quenching the design (a group solution), which can systematically classify, give a standard name, definition, effect, actual method, or even sample code. We don't have to make each time from the wheel (but also is not a circle). If the programmer says only Singleton, Proxy, Iterator, Flyweight, the designer immediately knows that a specific design is a particular design, with a specific logic to solve some specific problem, how good. This is exactly the precious experience of design concepts and actual logic, expressed in a concise and reusable form. [Gamma95] One book contains 23 Design Patterns in a well-organized. The main contribution of the four authors is not to create Patterns, but in the form of Patterns and the development of greetings. The Patterns name mentioned in the book has almost become the standard number of the OO design field. "Programmer" has a commentary for [Gamma95] in November last year, where the metaphor of Patterns is exciting: "Patterns need to repeated exercises to experience it." This is a bit like the formation of Go, Go is a summary of the master's law in a hundred years, but it is not easy to apply. It is necessary to choose the appropriate set of styles.

转载请注明原文地址:https://www.9cbs.com/read-207.html

New Post(0)