On Abstractions
1 Abstraction Definition
- ab·strac·tion abˈstrakSHən/ noun
- the quality of dealing with ideas rather than events.
- "topics will vary in degrees of abstraction"
- "the question can no longer be treated as an academic abstraction"
- synonyms: concept, idea, notion, thought, theory, hypothesis
More
- freedom from representational qualities in art. "geometric
abstraction has been a mainstay in her work"
2 Data Abstractions
- sets versus linear arrays, lists, hash table
- bags versus …
- binary tree eg is not definable in Java
- n-ary trees versus …
- Abstract Data Type (ADT)
- Algebraic Specs
- Stack: push, pop, top, isempty, cons
- Binary-Tree: …
3 Control Abstractions
- multiple assignment
- for-all
- map-reduce
4 Abstraction v Encapsulation
- Information Hiding
- Abstraction is about ignoring nitty-gritty details while keeping
essential details
- Encapsulation is about controlling access to methods that implement
abstractions.
5 OOP and Abstraction
- Design by Contract
- Java and C++ pretty good at encapsulation; pretty poor on
abstractions.
6 Java and Abstraction
abstract
key word has a "different" meaning
- abstract class: incomplete, cannot be instantiated
- abstract method: just a declaration, no body (implementation)
- interface:
public static
, final constant
or abstract method declarations