Skip to content

Feedback - #1

Open
github-classroom[bot] wants to merge 32 commits into
feedbackfrom
main
Open

Feedback#1
github-classroom[bot] wants to merge 32 commits into
feedbackfrom
main

Conversation

@github-classroom

@github-classroom github-classroom Bot commented Mar 21, 2023

Copy link
Copy Markdown
Contributor

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to main since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to main since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to main. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @PavlushaSource @AlexShmak @ALanovaya

Comment thread README.md Outdated
Comment thread settings.gradle.kts Outdated
Comment thread .github/mergeable.yml Outdated
Comment thread .github/workflows/CI.yml Outdated
Comment thread app/build.gradle.kts Outdated
Comment thread app/src/main/kotlin/trees/database/sqlite/avl/sqliteRepAVL.kt Outdated
Comment thread app/src/main/kotlin/trees/database/sqlite/avl/sqliteRepAVL.kt Outdated
Comment thread app/src/main/kotlin/trees/database/sqlite/avl/sqliteRepAVL.kt Outdated
Comment thread app/src/main/kotlin/trees/database/sqlite/avl/sqliteRepAVL.kt Outdated
Comment thread app/src/test/kotlin/trees/avltree/AVLTreeTest.kt Outdated
)
return parse(nodesRecords)
}
fun unloadTree(): RedBlackTree<String>? {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У нас оно не работает(
Всегда возвращает null

Comment on lines +33 to +37
"CREATE (:node {key : \"${node.key}\", " +
"value: \"${node.value ?: ""}\", " +
"isBlack: ${node.color == BLACK}, " +
"lkey: \"${left?.key ?: ""}\", " +
"rkey: \"${right?.key ?: ""}\"}) "

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такой запрос уязвим к инъекциям. Через интерполяцию вставлять параметры очень опасно

PavlushaSource and others added 6 commits May 3, 2023 02:08
* fix: Changed the files related to the project build and CI setup, changed mergeable

* Issue #12 done (#18)

* fix: Changed the logic of the findByKey function and initialization of trees

* fix: Changed the initialization of trees in the database

* fix: Rewrote all the bst methods without recursion and rewrote the tests for it

* fix: Rewrote the AVL tree and tests for it

* Refactor: rewrote the RBT and wrote tests for it [remove doesn't work!]

* Issue #20 done (#23)

* Feature: Added the ability to save string type keys in Sqlite database

* Fix: solved the problem with gradle build

* Issue #9 done

implemented json repo to save trees with keys of type String and Int and values of type String

* fix: Renamed function names to Json and SQLite repo
Also add README

* feature: Add jacoco coverage

* fix: jacoco wrote differently in CI

* fix: Found a bug in RBT remove

* feature: Added tests for SQLite database

* docs: Added explanations to the functions and removed unnecessary ones
…wing a tree with the necessary functionality for searching, inserting and removing with OpenRNDR library

@olgsm olgsm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом, я бы больше сфокусировался не на алгоритмах поворота вершин (хотя если они корректные, вы молодцы) -- задание-то, кмк, раньше было не совсем и не только про это (поправьте меня, если я не прав). Задание про аккуратный ООП дизайн, конечно, и про проектирование архитектуры своей маленькой либы -- но как ее потенциально смогут использовать? покрыты ли все сценарии? есть ли документация? насколько это все расширяемо, можно ли будет добавлять еще виды деревьев? а другие базы данных? а если я захочу что-то визуализировать, как мне к вам втыкаться?) и прочее, и прочее)

Если вам интересно и в кайф такая разработка, советую потратить немного времени (пока оно есть лол), порефлексировать и допилить, это правда хороший опыт.

Comment thread app/build.gradle.kts Outdated
dependencies {

// Neo4j
implementation("org.neo4j.driver", "neo4j-java-driver", "5.7.0")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В gradle проектах сейчас все чаще используют version-каталоги, советую почитать и потом перейти на их использование. Очень удобно шарить и контролировать версии зависимостей, особенно в большой монорепе с кучей саб-проектов


import com.fasterxml.jackson.annotation.JsonIgnore

@Suppress("UNCHECKED_CAST")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Обычно если приходится писать @Suppress("UNCHECKED_CAST") на весь класс - это признак того, что с архитектурой что-то не так :)

/**
* Adds a value to the tree by this key, if the key already exists, then overwrites the value
*/
open fun insert(key: K, value: V? = null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Публичные методы обычно ставят в начале файла, так удобнее читать код потом

internal var right: Subtree? = null
internal var left: Subtree? = null
@JsonIgnore
open var parent: Subtree? = null

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected? или хотя бы internal, но вообще делать что-либо internal ТОЛЬКО ради тестов — обычно плохая практика, предполагается что тесты на публичные методы класс уже достаточно unit. но тут уже на вкус и цвет :)

/**
* Searches for the next subtree in order
*/
private fun findMinimumTree(givenTree: Subtree): Subtree {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оч странный публичный метод, непонятно из названия о чем речь, если в остальном ваш класс - это просто мапа

val tree = reference("tree_id", TreesTable)
}

internal class AvlSubtree(id: EntityID<Int>) : IntEntity(id) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично комменту про TreeDatabase

throw IOException("Session failed", exeption)
}

} override fun close() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Форматирование?) Добавьте ktlint какой-нибудь, чтобы он орал каждый раз, если забываете пока на автомате Ctrl+Alt+L жать :)

* in other cases returns exception
*/
fun setTree(treeName: String, currentTree: AVLTree<*, String>, typeKey: String): Unit = transaction(db) {
if (typeKey != "Int" && typeKey != "String") throw IllegalStateException("Saving this type of key is not supported in the tree")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь и еще по коду кое-где - лучше кидать какие-то кастомные свои эксепшны о таких вещах, а не дженерик IllegalState

file.writeText(serialized)
}

fun getNamesTrees(): Any {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возвращать Any - плохой дизайн, нужно лучше возиться с системой типов. Это вообще очень мощная штука, на курсе по функционалкам это хорошо дают понять)


@TestMethodOrder(MethodOrderer.OrderAnnotation::class)
class SqliteRepAVLTest {
private val repo = SqliteRepAVL("src/main/kotlin/database/sqlite/TestDatabase")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это не совсем мок, конечно, - а что если бы SQLitе была не просто файликом?)
Но в целом, идея правильная.

Почитайте еще про dependency injection (DI) и том как его правильно делать, полезно будет. В котлине юзают Koin или Kodein обычно (но может и я отстал от моды уже лол). В этих же фреймворках обычно есть все чтобы мокать такие вещи.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants