Lecture: Interfaces, Make
- Interfaces: what services and access are provided?
The interface is in effect a contract between the supplier and the
customer. The desire is to provide services that are uniform and
convenient, with enough functionality to be easy to use but not so
much as to become unwieldy.
- Information Hiding: What information is visible and what is private?
An interface must provide straightfoward access to the components
while hiding the details of the implementation so they can be changed
without affecting users.
- Resource Management: who is responsible for managing memory and other
Here, the main problems are allocating and freeing storage, and
managing shared copies of information.
- Error handling: who detects errors, who reports them, and how? When
an error is detected, what recovery is attempted?
- CSV - Comma separated values
- CSV - Prototype library
- CSV - A library for others
- CSV - A C++ implementation
- Interface Principles
- Hide implementation details
- Choose a small orthogonal set of primitives
- Don't reach behind the user's back
- Do the same thing the same way everywhere
- Resource Management
- Free a resource in the same layer that allocated it
- Abort, Retry, Fail?
- Detect errors at a low level, handle them at a high level
- Use exceptions only for exceptional
This still holds for more formal languages (Java, C++),
though it seems the scripting world is using them a bit more liberally.