2

我正在尝试编写 Martin Fowler在此处找到的定期事件日历的实现,我了解其中的大部分内容,但在他的所有抽象类中,他传递了一个名为 eventArgs 的字符串作为参数。

例如:

class Schedule {
    public boolean isOccuring( String eventArg, Date aDate )
    public Vector dates( String eventArg, DateRange during )
    public Date nextOccurence( String eventArg, Date aDate )
}

有谁知道它是干什么用的?是否只是为了表明这只是伪代码而我应该把我的论点放在那里?

4

1 回答 1

1

In your comment, you write:

Okay so I think when he creates an instance of ScheduleEvent he would have you add a string sort of like event = new ScheduleEvent('myEvent') which would then be stored in the "event" variable. When you call isOccuring on the Schedule you pass the name of your event and it'll cycle through each SE object and see if they have the same name to then check if it is occuring.

Correct. It's simply a label for the event whose recurrence you're describing with a TemporalExpression. If you wanted to integrate your implementation with arbitrary existing systems, you might even make that an Object instead of a String, and then you could pass in some Event object defined elsewhere.

于 2018-07-15T02:56:11.410 回答