Object-oriented Ha

Source: Internet
Author: User

Today and people gossip in the unintentional mention of the day of the Dragon in the sword, this is an ordinary with a point weak protagonist, character complex. Back after a careful thought, I unexpectedly think his way to the road is quite enlightening, want to Jin Yong Master is philosophical well paid ah. Below to recall the Zhang master of the road to success, see if I have a worthy reference.

Object-oriented thought--the two veins of Ren-du
To open the two-vein, which is to practice higher martial arts must be through the steps, this people have seen the martial arts know, but also basic have seen (generally with the help of external forces, such as martial arts high-strength master, the ability of extraordinary props, etc.). The truth is also very simple, if the two meridians, the true airflow does not flow smoothly, this certainly can not play their own body the biggest energy.

Basically, anyone who has used object-oriented languages (Java, C + +, C #, etc.) can say the three main features of object-oriented: inheritance (operating mechanism), encapsulation (means), polymorphism (characterization change). But how many people have tried to understand the meaning behind these 6 words in depth? Object-oriented thinking is a great milestone in the history of software engineering. It provides a new approach to software design and development: that is, everything is an object. This kind of thought embodies people's re-understanding of the world. This understanding manifests in the actual action, is uses the object to express the world development all activities. In order to vividly describe the inheritance of the characteristics between things, "inheritance" was born, each object-oriented language is the use of inheritance mechanism to achieve the majority of code reuse. In order to describe the difference between things on the basis of the same characteristics, the "polymorphic" is created. In order to describe the completeness and relative closeness of things, "encapsulation" is put on the agenda, and details never need to be paid attention to. This is the object-oriented world view of the 3 fundamental features, but also the core of object-oriented design, only a deep understanding of them, your magic will be rapid.

Object-oriented design principles-nine-yang martial art
When you do any time, any occasion, only the object in the eyes, congratulations to you, the two veins have been opened, you can learn any advanced internal strength. Why first study internal strength, this everybody also familiar. No internal strength of the cooperation, any advanced moves are floating clouds. So to be invincible, must have a deep internal strength, such as nine Yang Martial.

The three main features of the

object are all used, indicating that everything in your eyes should be an object, you are already object oriented, but not that it is a good object-oriented. How to judge a system is good object-oriented? It is generally referred to the following "SOLID" standard:
single responsibility principle (SRP): Be a one-man person
only and do one thing, this principle not only applies to objects, It also applies to all programming elements, such as functions, variables, and so on. Of course, in the business model, one thing to achieve the ultimate is success, I personally feel that this article is also set up.
open closure principle (OCP): Most of the world is not destroying the original order
in the object world, adding new functionality generally means new objects, A good design also means that this new modification does not affect the existing objects significantly. This one is the simplest to understand and the most difficult to implement. Countless models and decoupling methods have been created to achieve this goal.
Richter substitution principle (LSP): When I grow up, I'll be you.
The parent class is used, and subclasses can use it. This article expects the subclass to not break the interface members of the parent class. Once destroyed, it can be bad if the contract is broken between people.
interface separation principle (ISP): Do not eat a mouthful of fat
interface is not too large, complex things are difficult to understand, difficult to expand, difficult to modify. The purpose of this article is similar to that of a single duty principle, but more emphasis is placed on the logical coherence and simplicity of the interface.
dependency inversion principle (DIP): Abstract art has vitality
between high-level and underlying components should be dependent on an abstract component. This article profoundly reveals the abstract vitality, abstract object is the most expressive object, because it is usually "invisible", can fill in the relevant details at any time.

In addition to these basic design principles, there are some derivative principles to master them, and you will be better oriented towards the object.
Dimitri rule: Try not to have sex with unrelated classes.
Don't let the class also catch the mysterious ambiguous relationship between people. The simpler the connection between objects, the easier it is to manage.
Hollywood rule: Don't call me, let me call you.
The movie often says that the single-line connection is the safest, so is also.
Use more combinations, use less inheritance
In addition to inheriting this strong constraint method, the combination of this weakly coupled relationship is more flexible.
Implementation relies on abstraction
This is commonly referred to as interface-oriented programming, which guarantees stable relationships between objects.

Mode-a great diversion of the universe
When Zhang Mowgli learned the nine Yang martial art, we found that no, incredibly the most common hair thieves are beaten, they have to fight him to fight against. What a invincible way to talk about it. But when he learned the great change of the universe, it was really like the Phoenix Nirvana, instantly became the super race. This truth seems to be very simple, the light has a deep internal strength, but not run freely, the full play of the internal strength of the moves, the same is not. Moves that is the experience of the predecessors of the summary, is the essence ah. By learning this, you have the capital to win the world.
There is no pattern in the world, the use of more people, there is a pattern. The model is the summary of experience, is the "great man" of painstaking efforts. Large patterns such as architectural patterns (hierarchies, Mvc,pac, blackboards, intermediaries, reflections, pipelines, micro-cores, rest architectures, etc.) describe the construction process of a large skeleton of a system, medium-sized patterns such as design patterns (GOF 23 modes, various design patterns in Posa), They describe the process of building components in subsystems, small patterns such as programming practices in various languages (idispose patterns in C #, counted point patterns in C + +, etc.), which describe the implementation of specific problems in a language solution Together, these patterns are the great diversion of the object-oriented programming process for specific problems.

Reconstruction-Taijiquan
Practicing Taijiquan is the need of extraordinary understanding, Tai Chi in order to operate, not the slightest imposition of constraints, this point of view of the original students are very clear. After the advent of Taijiquan, people just re-experience what is called with softness!
Refactoring is the process of fine-grinding code and is an essential skill for any veteran code farmer. Refactoring is not a non-purpose, and refactoring is a process of improving code readability and extensibility without changing the behavior of code.
The reason for refactoring is that code is also in line with the law of things, and there is a process from birth to growth, from strength to decay, from decay to decay, and gradually, unconsciously, from good to bad. No doubt, not all the rotten code is written once, perhaps the original code design is very good, but once changed by many people, it becomes bad, I think this people must have deep experience. Code is always written under the common "effort" of everyone.

If the above-mentioned techniques are traceable, the rules are relatively strong, relative, the reconstruction of the technology to be relatively softer, not so strong binding clauses, and although there are also like the "code bad Taste" of the great Works (refactoring a book) was born, but the usual people in the mind of the reconstruction of the impulse, It's not as strong as using the pattern, and it's not like the refactoring will be so important, just as the high people in the book don't even think of the slow and non-stationary style of taijiquan being so tough. Reconstruction, like Taijiquan, is a true "stream of consciousness".

Abstract and combination-lone nine swords

To say Jin Yong's novels the most powerful martial arts, that is not the big diversion of the universe, is not Tai Chi, is not a sunflower treasure, but the lone nine swords. Is that the realm of God and horse? Nine swords break the world any fist, qigong, concealed weapon, 18-like weapons ah. This is called "Invincible". Of course, this martial arts is not casually who can be practiced, that is, like Fox eldest brother as wisdom, free and easy, with a certain internal strength (later more auxiliary to Suck star Dafa), martial arts and miscellaneous small brother can practice, and this practice process is very long, according to wind old introduction, Fox brother to work hard for decades to fight the east undefeated.
Let's look at the magic of the original heroes of the whole life of the change of weapons: from the sword to the sabre, to the wooden sword, and then to No sword. We found that no, to the end of all the moves, the internal strength, integrated through, after the harmony, is the divine, this time also found all back to the beginning: The original martial arts is so simple, is to exercise and play the maximum energy of the human body, casually a wave of an incomparable power. Back to basics This is the Ultimate Warrior, the eternal behind the bronze door (from the tomb-robbing note book).
Whether it is the process-oriented, or object-oriented, whether it is a component-oriented, or service-oriented, in the final analysis of the world is only the abstract way and abstraction of the different granularity, the abstraction of the east to form a certain norms and processes, relying on these to solve the actual problem, this is programming. Abstraction and combination are the ultimate art.

Object-oriented Ha

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.