Implement the state-based counter prototype#138
Conversation
d-r-q
left a comment
There was a problem hiding this comment.
Ну и прошлые комменты надо править
| } | ||
| } | ||
|
|
||
| internal fun crdtResolve( |
There was a problem hiding this comment.
Эммм, это очень странно.
Зачем дублировать логику 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.
Симетрия и постоянство уровней абстракции - очень важные свойства кода.
Почитай 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.
Это тоже лучше утащить в
operator fun Number.plus(another: Number) = when (this) {
is Int -> this + another.toInt()
// ...
}| } | ||
|
|
||
| internal fun crdtResolve( | ||
| resolveEntity: (Gid) -> StoredEntity?, |
There was a problem hiding this comment.
resolveBaseEntity
И ваще лучше коммент к методу написать. Как писать хоршие комменты можешь почитать в Philosophy of Software Design и вроде том же Clean Code было
|
А что с правками по этому МРу? |
No description provided.