开发者

Design pattern: Generating daily and weekly tasks based on specifications

I am working on a project that has some inputs like task type and frequency. For example

if task type = Daily and frequency =2 then create 5 task every alternate day. if task type = Daily and frequency =3 then create 开发者_运维百科5 task on today and 3rd and sixth days. If task type = Weekly and frequency =2 then create 2 tasks every alternate week.

More over I have a calendar table so I need to check working day, if that is a weekend, that task should be generated on next working day. I have calendar_Holidays table as well so check and skin that date as well.

Can I use design pattern for this problem? can somebody show me how?


You might be interested in a paper about recurring events in calendars by Martin Fowler. It describes few very interesting techniques and patterns to use while dealing with scheduling events.


You are trying to apply design patterns too early in your implementation. Design patterns help when you have identified important classes and want to adjust their relationships, for example to reduce coupling and enable extension.

Here you have not yet identified any classes, and I would say that you haven't even got your requirements completely clear. On which days will weekly tasks be generated? What will you do for alternate days when you have a long weekend - in UK we could have Friday as public holiday, Sat, Sun as weekend, and Monday as public holiday - what's your rule now. Can you have monthly events? what other intervals? Again in UK we pay council tax monthly, but not in February and March, do you have cases like that?

So I'd recommend firs getting very clear the corner cases of your requirements. Then produce a natural OO design, and then look to see what patterns may help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜