Lecture Notes for Advanced Programming II

8 February 2001 - Libraries and Interface Design


  1. libraries and interfaces

    1. repetition is the mother of libraries

    2. desirable library features

      1. it works - a broken library is useless

      2. easy to learn - write my own

      3. easy to use - ditto

      4. costs less than benefits - conceptual, programming, and execution costs

      5. stability - no changes

    3. issues

      1. function - what does the library do

      2. detail - how much do i have to know

      3. resource management - who's responsible for what

      4. error handling -

  2. discovering libraries

    1. if you do something more than one time, write a library for it - command-line argument parsing; printing error messages; establishing and using network connections; variable-length lists of memory blocks

    2. data formats - comma separated lists

  3. prototypes and experimentation

    1. good libraries don't appear, they evolve

    2. prototyping is one approach - particularly at the start

    3. use and change - early on; stability

    4. anticipate or avoid changes - simplify function; extend generality; improve performance; fix errors

    5. increasing use freezes libraries

  4. durable libraries

    1. function (interface) - simple, complete functions

    2. information hiding - the more the better; change resistance; protection

    3. resource management - memory, files

    4. error handling - a big problem; knowledge vs recovery

    5. documentation - all this has to be documented

  5. c++ library design

    1. the wrapper pattern - a way to unify libraries

    2. multiple inheritance, abstract virtual classes, and interfaces

  6. principles

    1. information hiding - the more the better; safety, change; no globals

    2. small, well defined purpose - easy to understand; most combinations make some sense; narrow interfaces

    3. no surprises - performance; resources; errors; data

    4. follow conventions consistently - copying and assignment; indexing from 0

  7. resource management

    1. resource management is important, but who should do it

    2. resources - memory; open files; shared state

    3. initialize, manipulate, share and copy, decommission

    4. information hiding helps answer a lot of these questions

    5. whatever makes it unmakes it

  8. errors

    1. low-level detection, high-level recovery

    2. exceptions are exceptionally bad

    3. explicit routines for dealing with errors - tends to get complicated quickly

  9. user-interface design

    1. you don't know jack - there are some rules about what not to do

    2. prototype, prototype, prototype

    3. review, test, and review...


This page last modified on 8 February 2001.