proofofconcept icon indicating copy to clipboard operation
proofofconcept copied to clipboard

refactor code using data-driven design approach

Open bhpayne opened this issue 4 years ago • 0 comments

Advice from @pqnelson: code like (https://github.com/allofphysicsgraph/proofofconcept/blob/gh-pages/v7_pickle_web_interface/flask/validate_steps_sympy.py#L130-L402) could be refactored using some data-driven design, using something like a dictionary inference_rules so you could do something like

rule = inference_rules.get(step_dict["inf rule"], None)

if rule:
     logger.info("[trace end " + trace_id + "]")
     return rule(latex_dict)
else:
     logger.error("unexpected inf rule:" + step_dict["inf rule"])
     raise Exception("Unexpected inf rule: " + step_dict["inf rule"])

bhpayne avatar Aug 10 '20 22:08 bhpayne