A fine way to solve problems
xhae@STARTLINK LIVE
2016. 02. 12
Problem Solving
vs
Field Development
Solve a problem
- Think
- Code
- Goto Think while not accepted
Code a general program
- Think
- Code
- Goto Think while not qualified
Similarities
Differences
Similarities
- Procedure
Differences
Similarities
- Procedure
- Tool
Differences
Similarities
- Procedure
- Tool
- Due
Differences
Similarities
- Procedure
- Tool
- Due
- Bugs
Differences
Similarities
- Procedure
- Tool
- Due
- Bugs
- ...
Differences
Similarities
- Procedure
- Tool
- Due
- Bugs
- ...
Differences
- Scale
- Complexity
- ...
Similarities
- Procedure
- Tool
- Due
- Bugs
- ...
Differences
- Scale
- Complexity
- ...
They're both programming!
Take benefits of "programming"
Abstraction
about making a trustable blackbox
NO MORE
...but still better than making no layer at all.
void main() {
input();
process();
output();
}
Quiz
Quiz
Quiz
Quiz
Quiz
Quiz
dist
P1
P2
double dist = (P1 - P2).size();
Quiz
dist
P1
P2
double dist = (P1 - P2).size();
double theta = acos(R / dist);
theta
theta
R
Quiz
dist
P1
P2
double dist = (P1 - P2).size();
double theta = acos(R / dist);
Point base = (P1 - P2).resize(R);
theta
theta
base
R
Quiz
dist
P1
P2
double dist = (P1 - P2).size();
double theta = acos(R / dist);
Point base = (P1 - P2).resize(R);
Point ans[] = {P2 + base.rotate(theta),
P2 + base.rotate(-theta)};
theta
theta
base
base.rotate(theta)
base.rotate(-theta)
Base struct for Point
struct Point {
double x, y;
Point operator – (Point arg) { return Point{x – arg.x, y – arg.y}; }
double size() { return hypot(x, y); }
Point resize(double newSize) {
double ratio = newSize / size();
return Point{x * ratio, y * ratio};
}
Point rotate(double theta) {
return Point{x * cos(theta) – y * sin(theta),
x * sin(theta) + y * cos(theta)};
}
};
Abstraction
- is the way we think
Abstraction
- is the way we think
- makes code simpler
Abstraction
- is the way we think
- makes code simpler
- Easy to debug / review
And?
Much more similarities to go!
Thank you
A fine way to solve problems
By xhae
A fine way to solve problems
- 2,369