Colon Class § 3.1: Generic paradigm

Source: Internet
Author: User
Tags data structures

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. ”

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.