Lecture Notes for Advanced Programming II
8 February 2001 - Libraries and Interface Design
- libraries and interfaces
- repetition is the mother of libraries
- desirable library features
- it works - a broken library is useless
- easy to learn - write my own
- easy to use - ditto
- costs less than benefits - conceptual, programming, and execution
costs
- stability - no changes
- issues
- function - what does the library do
- detail - how much do i have to know
- resource management - who's responsible for what
- error handling -
- discovering libraries
- 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
- data formats - comma separated lists
- prototypes and experimentation
- good libraries don't appear, they evolve
- prototyping is one approach - particularly at the start
- use and change - early on; stability
- anticipate or avoid changes - simplify function; extend generality;
improve performance; fix errors
- increasing use freezes libraries
- durable libraries
- function (interface) - simple, complete functions
- information hiding - the more the better; change resistance; protection
- resource management - memory, files
- error handling - a big problem; knowledge vs recovery
- documentation - all this has to be documented
- c++ library design
- the wrapper pattern - a way to unify libraries
- multiple inheritance, abstract virtual classes, and interfaces
- principles
- information hiding - the more the better; safety, change; no globals
- small, well defined purpose - easy to understand; most combinations
make some sense; narrow interfaces
- no surprises - performance; resources; errors; data
- follow conventions consistently - copying and assignment; indexing from
0
- resource management
- resource management is important, but who should do it
- resources - memory; open files; shared state
- initialize, manipulate, share and copy, decommission
- information hiding helps answer a lot of these questions
- whatever makes it unmakes it
- errors
- low-level detection, high-level recovery
- exceptions are exceptionally bad
- explicit routines for dealing with errors - tends to get complicated
quickly
- user-interface design
- you don't know jack - there are some rules about what not to do
- prototype, prototype, prototype
- review, test, and review...
This page last modified on 8 February 2001.