计算之智与哲学之慧分享 http://blog.sciencenet.cn/u/huangfuqiang

博文

Generic programming

已有 3426 次阅读 2009-6-26 20:10 |个人分类:计算机软件理论与工程|系统分类:海外观察| Programming, Generic

信息来源: http://en.wikipedia.org/wiki/Genericity
       Generic programming is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters. This approach, pioneered by Ada in 1983, permits writing common functions or types that differ only in the set of types on which they operate when used, thus reducing duplication. Software entities created using generic programming are known as generics in Ada, Eiffel, Java, C#, Visual Basic .NET and Haskell; templates in C++; and parameterized types in the influential 1994 book Design Patterns. The authors of Design Patterns note that this technique, especially when combined with delegation, is very powerful but that "Dynamic, highly parameterized software is harder to understand than more static software." (Gang of Four 1995:21)

Generic programming refers to features of certain statically typed programming languages that allow some code to effectively circumvent the static typing requirements. For instance in C++, a template is a routine in which some parameters are qualified by a type variable. Since code generation in C++ depends on concrete types, the template is specialized for each combination of argument types that occur in practice. Generic programming is commonly used to implement containers such as lists and hash tables and functions such as a particular sorting algorithm for objects specified in terms more general than a concrete type.

Contents



https://blog.sciencenet.cn/blog-89075-240479.html

上一篇:纯XML数据库管理系统OrientX3.5
下一篇:计算机相关主题网站Dedoimedo
收藏 IP: .*| 热度|

0

该博文允许实名用户评论 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-2 04:33

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部