The C # Essence and the CLR via C # Chinese translation are not unpleasant,

Source: Internet
Author: User

The C # Essence and the CLR via C # Chinese translation are not unpleasant,

C # Essence and CLR via C # are two good books. Teacher Zhou may be busy with things and he is too busy to translate.

If you are busy, don't take so many jobs.

Now we are talking about supply-side reform, and we are all vigorously advocating the craftsman spirit. We are doing technology, but we should be steadfast, right?

Compare the difference between the CLR via C # Translated by Mr. Li Jianzhong.

 

Here, we will only record the several problems we have discovered as an example.

In fact, Examples of improper translation similar to the following can be seen everywhere in these two Chinese translations. It doesn't matter if you don't go into it, but if you are seriously studying the two books, this ubiquitous flaw will greatly affect your reading experience and even your understanding of the original author's thoughts.

Teachers Zhou may not have read the two translations before they are published. Otherwise, how can they not be found and corrected if they are not logical?

When we learn the version translated by Mr. Li Jianzhong, it is like learning skills with two masters at the same time. The reader not only learns the knowledge from the original author, but also learns a lot of nutrition from the translator.

What should I do when I read the translation of teacher Zhou? Read-Only Chinese translations cannot be understood. You can refer to the original Chinese translations at any time. A good book can't be found. If you lose trust in the translator, you must always be careful when reading it.

 

Of course, I have learned a lot from teacher Zhou's translation. Here, I just hope that Mr. Zhou can do a better job and contribute better products to help these C # learners.

 

C # Essence version 4

7.3.3 comparison between explicit and implicit Interfaces

Original article:

The key difference between implicit and explicit member interface implementation
Lies not in the syntax of the method declaration, but rather in
The ability to access the method by name through an instance of the type
Rather than via the interface.

Translations in the original book:

For implicit and explicit interface members, the key difference lies not in the syntax of member declaration, but in the ability to access members through type instances rather than interfaces.

It should mean:

An explicit or implicit method is used to implement interface members. The key difference is not that the syntax used to declare interface members is different,: the interface members implemented in implicit mode can be directly called by the Instance Object of the class. For an interface implemented in explicit mode, you must first convert the Instance Object of the class to the interface type before calling.

Section 7.5, page 224

Original article:

In contrast, implementing ISettingsProvider assumes that there is
Never a reason to have a class that can write settings without reading them.
The inheritance relationship between ISettingsProvider and IReadableSettingsProvider, therefore, forces the combined total of both interfaces on the ISettingsProvider class.

Translations in the original book:

On the contrary, the implementation of ISettingsProvider is based on the premise that no class can be written but cannot be read. Therefore, the inheritance relationships between ISettingsProvider and IReadableSettingsProvider force the two interfaces to be merged on the FileSettingsProvider class.

How can I merge the two interfaces?

The reason should be: ISettingsProvider designers inherit from IReadableSettingProvider, instead of providing the two interfaces to the user separately and in parallel. It is based on the following considerations: no class can be written but not
Read settings. Using the Inheritance Method forces the user to implement both interfaces at the same time (one write setting and one read setting ). If the two interfaces are provided to the user in parallel independently, the user may only implement the write interface instead of the read interface. This is not in line with the regular.

 

Page 1, about using interfaces to implement multi-Inheritance

Original article:

One possible improvement that works if the implemented members are methods (not properties) is to define interface extension methods for the additional functionality "derived" from the second base class. an extension method on IPerson cocould provide a method called VerifyCredentials (), for example, and all classes that implement IPerson-even an IPerson interface that had no members but just extension methods-wocould have a default implementation of VerifyCredentials (). what makes this approach viable is the fact that polymorphism is still available, as is overriding. overriding is supported because any instance implementation of a method will take priority over an extension method with the equivalent static signature.

Original book translation:

If the implemented member is a method (rather than an attribute), there is a way to improve it. Specifically, the interface extension method is defined for the additional functions derived from the second base class. For example, you can define the extension method Veri statement Credentials () for the on in the IPe (). In this way, all classes that implement IPerson (even if the IPerson interface has no members, only the extension method) will be implemented by the default Implementation of lerifyC Tuo dentials.This is feasible because of polymorphism and rewriting. Rewrite is supported because any instance implementation of the method takes precedence over the extension method with the same static signature.

I am not very clear about the ideas and technologies about polymorphism discussed in the original book, but I feel that this sentence added to the blacklist should be translated as follows:

This is feasible because the fact that the polymorphism mechanism remains effective when overriding is performed. Because the implementation of the Method Instance (that is, the Implementation defined in the class) has a higher priority than the implementation of the extension method with the same static signature.

I think the original article means this: When you rewrite the extension method with the same static signature as the interface method in the form of an instance method, because the instance method has a high priority, during use, instance methods are called preferentially, which achieves polymorphism. Therefore, it is feasible to use the interface extension method to implement multi-inheritance. This is because the multi-base class inheritance method perfectly supports polymorphism. If the multi-inheritance function is implemented using the interface extension method, polymorphism cannot be perfectly supported, this method is not feasible.

 

Related Article

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.