-
Notifications
You must be signed in to change notification settings - Fork 0
/
2_framework.rb
52 lines (43 loc) · 1.42 KB
/
2_framework.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module ProblemSolver
def solve(problem, is_root_problem: false)
while problem.still_relevant?
begin # = "try" in other programming languages
root_problem = self.identify(problem)
if problem != root_problem
is_root_problem = false
return self.solve(root_problem, is_root_problem: true)
end
if problem.manageable?
solution = self.build_solution(problem)
else
subproblems = self.decompose(problem)
sorted_subproblems = self.prioritize(subproblems)
solution = []
sorted_subproblems.each do |subproblem|
solution.append(self.solve(subproblem))
end
end
self.test_and_analyze(solution, problem)
return solution
rescue UnderstandingOfProblemHypothesesOrSolutionUpdated > exception # = "catch" in other programming languages
if is_root_problem
next
else
raise exception
end
end
end
end
def identify(problem); end
def build_solution(problem); end
def decompose(problem); end
def prioritize(problems); end
def test_and_analyze(solution, problem); end
end
class Problem
def manageable?; end
def still_relevant?; end
end
solution_and_result = ProblemSolver.solve(Problem.new, is_root_problem: true)
lesson_learned = retrospect(problem, solution_and_result)
communicate(problem, solution_and_result, lesson_learned)