According to unofficial history legend, that year Song Zhezong most favored concubine is Liudefei. Liudefei, although deeply favored by the emperor, but can not give birth. Liudefei to compete for the Queen's position, to improve their own price, then came up with "borrow pregnant" trick. She intends to lure Song Jinzong by using a maid with a somewhat feminine surname, Lee, beside her. At the time of bathing in the Liudefei, really lucky this Li surname maid, soon this maid on pregnancy, this makes Liudefei also pretend to be pregnant, in fact, maid pregnancy is true, Liudefei just arrange tricks pretend. When the birth of October, the "Two" dragon species have been born. Liudefei took a civet cat for the Prince's despicable means, let the real will li surname maid limbo, but his wish to boarded the dream of the Queen throne.
on today, Liudefei must be an object-oriented master. She understands the "Richter replacement Principle":
-Create "parent class" – Pregnant women, pregnant women have two major characteristics: pregnancy, baby.
-then create an example of two pregnant women: Liudefei and the maid of the surname Li.
-Finally in the run, with their own replacement of the real pregnant woman Lee Maid, successfully deceived the emperor.
The ability to dynamically replace at run time is due to the fact that Liudefei's behavior completely inherits the characteristics of a pregnant woman.
Finally, the definition of the Richter replacement principle is given:
On the Richter scale replacement, LSP (Liskov Substitution Principle), where all references to base classes must be able to transparently use objects of their subclasses. In layman's words, as long as the parent class can appear where subclasses can appear, and the substitution of subclasses will not produce any exceptions.
We know that the three major characteristics of object-oriented language are inheritance, encapsulation, polymorphism, the principle of the Richter substitution is to rely on inheritance, polymorphism, to establish the abstraction, through the abstract establishment of norms, at runtime to replace the specific objects, to ensure the scalability of the system, flexibility.
Often and open closure principle is not abandoned.
Six principles of design pattern: Civet cat for Prince--the replacement principle of the Richter scale