-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implement the state-based counter prototype #138
base: master
Are you sure you want to change the base?
Conversation
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.
Ну и прошлые комменты надо править
@@ -72,6 +71,51 @@ internal fun lastWriterWinsResolve(resolveAttrName: (String) -> Attr<Any>?): (Li | |||
} | |||
} | |||
|
|||
internal fun crdtResolve( |
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.
Эммм, это очень странно.
Зачем дублировать логику lastWriterWinsResolve? А тесты не дублировать?
// temporary dirty hack until crdt counter or custom resolution strategy support is implemented | ||
attr == Instances.nextEid -> listOf((eavsFromA + eavsFromB).maxByOrNull { it.eav.value as Int }!!.eav) | ||
attr.list -> (eavsFromA + eavsFromB).map { it.eav }.distinct() | ||
DataType.ofCode(attr.type)!!.isCounter() -> { |
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.
Симетрия и постоянство уровней абстракции - очень важные свойства кода.
Почитай Implementation Patterns (Symmetry) и Clean Code (G34: Functions Should Descend Only One Level of Abstraction)
А эту портянку вынеси в отдельный метод
Eav( | ||
eavsFromA[0].eav.gid, | ||
eavsFromA[0].eav.attr, | ||
if (previous is Byte && latestFromA is Byte && latestFromB is Byte) latestFromA + latestFromB - previous |
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.
Это тоже лучше утащить в
operator fun Number.plus(another: Number) = when (this) {
is Int -> this + another.toInt()
// ...
}
@@ -72,6 +71,51 @@ internal fun lastWriterWinsResolve(resolveAttrName: (String) -> Attr<Any>?): (Li | |||
} | |||
} | |||
|
|||
internal fun crdtResolve( | |||
resolveEntity: (Gid) -> StoredEntity?, |
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.
resolveBaseEntity
И ваще лучше коммент к методу написать. Как писать хоршие комменты можешь почитать в Philosophy of Software Design и вроде том же Clean Code было
А что с правками по этому МРу? |
No description provided.