-
Notifications
You must be signed in to change notification settings - Fork 154
fix: window implementations #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
53414eb to
6354f22
Compare
|
|
||
| func (w windowV1) GetSize() string { | ||
| return w.size | ||
| if w.size != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if defaults are set before hand at the time of initialization of window
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default value is being set in the implementation under method getFieldValues. if we move the default value into the constructor, then that constructor has to deal with two different default values, one for version 1 and another is for version 2. I believe the current constructor shouldn't handle such a thing.
however, if we really want to specify the default value during construction, we can create unexported constructors for window version 1 (and version 2 as well, if required). each of them will handle the default value for each one. meaning, the current constructor do not need to deal with it. for example:
NewWindow() {
if version == 1 {
newWindowV1()
} else {
newWindowV2()
}
// each constructor will specify default value| } | ||
|
|
||
| var truncateTo, offset, size string | ||
| if spec.Task.Window != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need this check? and these intermediate variables we can directly refer to the window variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is to avoid panic. for example, the spec being used does not have Window field being configured, meaning it's nil. if we do not check it first and access the field Window, panic will hapen
| } | ||
|
|
||
| version := spec.Version | ||
| if version == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be handled within the constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is in case the job spec version is not specified. it's like a default value. the constructor's responsibility is construct a window based on valid inputs, or return error otherwise. if there's any invalid input such as version, I believe the constructor shouldn't assume the version of a spec. if there's a strong reason to do otherwise, then we need to at least change the function name to be not NewWindow
3f5f3f2 to
3efac5f
Compare
Note: these unit tests might not make sense at some point, as the old implementation is buggy. The old version is retained as much as possible, to allow for short-term backward compatibility. Later, old version (or in this case version 1) will be deprecated
3efac5f to
617e630
Compare
…n't implement it, avoid saving OldWindowSize & Offset as it is not needed
cf77f18 to
a8a03a1
Compare
This PR is to fix and add additional implementations for the targetted branch, as the source branch is extended on it. This PR is related to this issue.