Abstraction = Interface (What it does) + Implementation (How it does it)
Abstraction has Multiple Layers Seven Steps of solving a problem:
- Work Example By Hand (Solve Small instance by hand | unclear problem | Domain Knowledge )
- Write Down What you did (Write Down Exact Steps | Just that instance | Tricky: Do without thinking)
- Find Patterns (Algorithm for any instance | Repetitions | Conditions | Values, Try step1+2 again | Different Inputs)
- Check By Hand (Incorrect Pattern? Check with different inputs)
- Translate To Code (Programming Language)
- Run Test Cases
- Debug Failed Test Cases
- Boxes that holds value
- Declare with var
- Assign with =
- Combinations of variables, constants, operations
- Create an image
- Perform some(complex) operation
- Act on a object
- Can have parameters
-
Abstraction
-
Separate interface from implementation
-
Implemention
Call image.getWidth()
, get width of image
- Interface
- Code in DLTP library(not shown)
- No need to see!
-
Keeps track of it with the value
-
Called dynamically typed
1. Observe a phenomenon
--> 2. Ask a question
--> 3. Gather Information & Apply Expert Knowledge
Gather Information = Print Statements, Debugging Tools, Execute Code by Hands
Expert Knowledge = Comes with Experience
--> 4. Form Hypothesis
Good Hypothesis are: Testable (Prediction about behaviour)
Actionable (Can fix program if true)
Being specific helps with both
--> 5. Test Hypothesis:
Run program
Behaviour matches predictions:
No: reject hypothesis
Yes: more confident
Confident enough? Accept.
--> 6. (Reject | Accept) Hypothesis
Temptation: "Maybe if I just change ..." (poor idea)
Metaphor: Medical doctors