1 / 5

E81 CSE 532S: Advanced Multi-Paradigm Software Development

E81 CSE 532S: Advanced Multi-Paradigm Software Development. Introduction to Generic Programming in C++. Chris Gill Department of Computer Science Washington University, St. Louis cdgill@cs.wustl.edu. Each Paradigm Has a Particular View.

garnet
Download Presentation

E81 CSE 532S: Advanced Multi-Paradigm Software Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. E81 CSE 532S: Advanced Multi-Paradigm Software Development Introduction to Generic Programming in C++ Chris Gill Department of Computer Science Washington University, St. Louis cdgill@cs.wustl.edu

  2. Each Paradigm Has a Particular View “Computer programming is largely a matter of algorithms and data structures.” • Austern pp. 3 (Generic Programming Paradigm) • Object-based might say “methods and data” • OO might say “inheritance and polymorphism” • Patterns might say “design forces and contexts” • And so forth …

  3. What is the STL? • An abstract library of concepts • A formal hierarchy of software requirements • A library of interchangeable modules • Algorithms • Containers • Iterators • Function objects, and much more • A flexible and efficient software framework • An extensible platform for software development

  4. What is Generic Programming? • An abstraction technique for algorithms • Argument types are as general as possible • Separates algorithm steps & argument properties • What GoF design pattern does this resemble? • Type requirements can be specified, systematized • Can cluster requirements into abstractions • Termed “concepts” • Concepts can refine other concepts • Captures relationships between concepts • Analogy to inheritance hierarchies • A type that meets a concept’s requirements • Is a “model” of the concept • Can be plugged in to meet that set of requirements

  5. Generic Algorithm Example • STL linear search (based on Austern pp. 13): template <typename Iterator, typename T> Iterator find2 (Iterator first, Iterator last, const T & value) { while (first != last && *first != value) { ++first; } return first; } • A generic algorithm • Searches any one-dimensional sequence of elements, for any type on which the operators work

More Related