Created
January 29, 2018 07:23
-
-
Save geekKeen/e236d43b9dcbb6e62e22beed19fcee26 to your computer and use it in GitHub Desktop.
Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find an insteresting code about the relationship `Schedule` and `Job` in apschedule | |
Class Job(obejct): | |
def __init__(self, scheduler, id, **kwargs): | |
self._scheduler = scheduler | |
self.id = id | |
def modify(self, job, **changes): | |
self._scheduler.modify_job(self.id, **changes) | |
def _mopdify(self, **changes): | |
pass | |
# ... | |
class Scheduler(object): | |
def modify_job(self, **kwargs): | |
job, jobstore = self._lookup_job(job_id, jobstore) | |
job._modify(**changes) | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
apschedule_job.py
Job 和 Scheduler 的关系很有趣
分析一下这样写法的优势和缺点:
优势:
这里如果是自己写的话,我一定会将 job和scheduler拆开写, 先申明scheduler, job 等
缺点:
这里的优势也是劣势 如果我需要直接获取背后隐藏的东西,就会很麻烦, 所以这里的方法需要权衡
需要查看<重构> 类之间的关系说明