General paradigm of the third lesson (1)
Guide before class
This lesson introduces four common programming paradigms: generics, metaprogramming, slice, and event-driven.
This lesson is divided into four sections--
1. Generic Paradigm
2. Super Paradigm
3. Sectional Paradigm
4. Event-Driven
3.1 Generic Paradigm--an abstraction of your algorithm
To the class of miscellaneous, to a line million-"Xun Zi Wang System chapter"
Keywords: programming paradigm, generic programming, STL, algorithm
Summary: A brief discussion of generic programming
? Questions
What are the advantages of generic programming?
What are the elements of STL? What are their roles?
What is the generalization object for generic programming?
What is the core idea of generic programming?
: Explain
The colon reopened: "You will not often encounter this scenario: over and over again write similar code, the intention to merge it, but for a variety of reasons can not be fulfilled." ”
"Yes, sometimes two functions are almost identical, because some parameters do not match and cannot be merged," said the comma. ”
"There is a programming paradigm that solves this problem by breaking down barriers between different data structures and making your code no longer bloated, which is generic programming." "The tone and rhetoric of the colon is reminiscent of the TV's weight-loss ads," Generic programming, referred to as GP, the basic idea is: the algorithm and its role of the data structure separation, and the latter as far as possible generalization, maximize the implementation of algorithm reuse. This generalization is based on template (template) parametric polymorphism (parametric polymorphism), which is not only more generic and more efficient than OOP based on inherited subtype polymorphism (subtype polymorphism). This cannot be said to be an abnormal number--we know that universality is often at the expense of efficiency. If there is a price to be found, it is slightly more complex and slightly less readable. GP's most famous representative is the STL (Standard Template Library) in C + +, and then absorbed by java,c# and so on. In addition, some functional languages such as OCaml, Standard ML, Generic Haskell also support GP. ”