Skip to content

New HttpStubDAO #84

Merged
merged 1 commit into from
Aug 8, 2023
Merged

New HttpStubDAO #84

merged 1 commit into from
Aug 8, 2023

Conversation

ashashev
Copy link
Contributor

Added new HttpStubDAO. It's first step in adding support of using a different database from MongoDB. New data access layer should hide building of databases queries.

@ashashev ashashev marked this pull request as draft July 28, 2023 15:55
@ashashev ashashev force-pushed the feature/new-stub-dao branch 4 times, most recently from 17fb7b9 to c5aeaef Compare July 30, 2023 16:43
.github/workflows/ci.yml Outdated Show resolved Hide resolved
* @param count
* количество заглушек, отображаемых на странице
*/
final case class StubFetchParams(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Не очень понятен смысл этих моделей, почему просто не передавать несколько параметров в метод?

Copy link

Choose a reason for hiding this comment

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

Мой главный аргумент такой: API остаётся стабильным при необходимости добавить новые параметры

Copy link
Collaborator

Choose a reason for hiding this comment

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

При этом в случае добавления параметра всё равно придётся править все места, где происходит вызов (ну, в данном случае где собирается модель)... Ещё и аллокация паразитная

Copy link

Choose a reason for hiding this comment

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

Лучше править меньше мест. По факту:

  • в обоих вариантах правки: реализации, вызовы
  • в варианте с доп.параметром добавляется: определение метода в интерфейсе + в каждой реализации

добавлю ещё, что после n-ного параметра возникнет соблазн задать дефолтные значения, чтобы упростить вызов. и тут могут быть неоднозначности с оверрайдами

Copy link
Collaborator

Choose a reason for hiding this comment

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

Оверрайды зачастую не нужны когда можно обойтись дефолтными значениями

Copy link
Collaborator

Choose a reason for hiding this comment

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

Количество мест, в которых нужно править - одинаковое. Если делать refactor -> introduce parameter, то работы не больше, чем при добавлении поля в кейскласс

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@danslapman, извини, большинством оставим кейс классы. Если мы ошибаемся и это окажется лишним, то переделаем.

Copy link
Collaborator

@danslapman danslapman Aug 8, 2023

Choose a reason for hiding this comment

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

@ashashev можно хотя-бы в отдельный файл модели вынести :-(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Да, без проблем, в следующем PR вынесу в отдельный файл.

@ashashev ashashev force-pushed the feature/new-stub-dao branch 2 times, most recently from f5084ca to 02724de Compare August 3, 2023 20:29
backend/build.sbt Outdated Show resolved Hide resolved
@ashashev ashashev marked this pull request as ready for review August 5, 2023 12:47
@ashashev ashashev changed the title [WIP] new HttpStubDAO New HttpStubDAO Aug 5, 2023
@ashashev ashashev force-pushed the feature/new-stub-dao branch 2 times, most recently from 1b69087 to 1dcd7f8 Compare August 8, 2023 08:48
Add dal2.HttpStubDAO and impl for MongoDB that hides logic of building
queries to Database.

Added a DSL that lets describe an action sequence and then  generates
scalatest, executing it and markdown files containing curl commands
for these actions.
@c0d3r85
Copy link

c0d3r85 commented Aug 8, 2023

LGTM

@ashashev ashashev merged commit 8087f54 into main Aug 8, 2023
4 checks passed
@ashashev ashashev deleted the feature/new-stub-dao branch August 8, 2023 11:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants