Colon and his students (serial 25)--Software strain

Source: Internet
Author: User
Tags abstract object model

25. Software strain

Latent its heart can view the world of the reason, will its heart can change the world--"Lu Kun Moan"

As soon as the seventh lesson opened, the colon asked a question: "If you replace all private keywords in a Java program with public, does the program work?" ”

"It should work, unless--it can't work before." The question mark answered cautiously.

The colon then asks: "So why bother to distinguish them?" ”

Exclamation mark: "Of course it is for information hiding." ”

Colon Step by Step press: "Hide what information?" And why should I hide it? ”

The exclamation mark should be: "The state of the object needs to be hidden." If the state of an object is exposed directly, allowing the client to modify it arbitrarily, it may destroy the intrinsic logic of the object. ”

The colon is still in pursuit: "Then why does the object's methods need to be hidden?" ”

"I used to have this question, and the most interesting thing about reading other people's code is the private way." "Quotes Buta.

The comma amused him: "It seems that you have a peeping addiction." ”

Quotes secretly kicked the comma One foot: "Now I understand that this is to implement the data abstraction, the interface and the implementation of the separation." ”

The colon does not stop: "What is the real benefit of this abstraction?" ”

"On the one hand, the abstract interface describes a class of the most essential behavioral characteristics, on the other hand, the implementation of the specific changes at any time, hide them to ensure that such changes will not affect customer code." ”

"That's the point!" said the man. "The colon finally stopped questioning," software and hardware, not only intangible and tangible, but also change and curing of the other. The so-called change, refers to the source code at any time may need to change. A software modification maintenance time usually exceeds the written time, the more complex the more mature program is the more so. The difficulty of software is two: one is the complexity of logic, the other is the change of demand. Many programmers value the former and underestimate the latter and spend most of their time looking for solutions rather than choosing solutions. They are dazzled and yuqi but puzzled by the naturalness, but the code is not only difficult to understand and easy to make mistakes, and because of its low universality and the impact of the change is greater. As we all know, the most taboo moves with the old, the old is difficult to change, once the opponent sees the consequences of unimaginable. Similarly, motionless volley is only a film and television works to attract eye-catching eyes of the scene, the actual combat rarely appear, cover because the air is not easy to change strokes. Of course everything has degrees, no one recruit old, there is no use of real, it is difficult to complete a fatal blow. It is reflected in software that excessive design can cause unnecessary complexity and loss of efficiency. ”

All think, and on the long absence of martial arts class.

The colon gushed: "Word, soft software, embodied in the ability to adapt to change." Many programming ideas, including OOP, are based on this theme, and abstraction and encapsulation are typical representatives. Abstract an object model that is the most essential and thus most difficult part of a class of objects to be refined out, and encapsulation--precisely, information hiding--is to the non-essential, easy to change the part of the hidden, so that a class divided into yin and yang two sides. Because of the changes occurred in the shade, the external is shielded, so the modification of the face without involving customers worry, thereby improving the software's ability to resist. Some people mistakenly believe that information hiding is due to software security considerations, but it is a plausible appearances. ”

Question mark question: "What are the main changes in software?" ”

"Software changes are broadly divided into two types: structural changes that are made out of intrinsic requirements, usually for the purpose of improving software quality, called refactoring (refactoring), and functional changes for external requirements, usually for customer needs." The ideal abstraction and encapsulation should be able to avoid the impact of the first class of changes on the client code and minimize the side effects of the second type of change. There are examples of problem easier that pay a huge price for subtle changes. The ' millennium bug ' is the most typical example, and when the 32-bit IPv4 are all replaced by 128-bit IPv6, the cost is comparable much. It can be seen that information hiding, especially the structural information hidden is how important! Let's look at a simple example. "Colon opens the slide--

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.