Skip to content

Instantly share code, notes, and snippets.

@david-shiko
Created January 28, 2023 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-shiko/3e32845ed94dc080d1029e46699e44ea to your computer and use it in GitHub Desktop.
Save david-shiko/3e32845ed94dc080d1029e46699e44ea to your computer and use it in GitHub Desktop.
mknltech
// RU
1. Прежде всего нужен точка ввода данных программу, в нашем случае это HTTP запросы.
Задача точки входа - принятие и преобразование входных данных во внутренний формат данных приложения.
Важно: приложение не должно зависеть от точки входа.
При необходимости мы должно быть в состоянии легко поменять HTTP запросы на CLI, или даже bluetooth :).
Это всего лишь способ получения входных данных.
2. Точка входа передает управление заранее определенному событию.
Событие - это набор из логических "бизнес" действий (набор методов разных классов).
Пример: логирование, аналитика, отправка уведомлений, целевое действие и т.п.
 3. Класс - отражает возможности нашего бизнеса (заказ такси, поиск свободных машин, расчет стоимости и т.п.)
Внутри его методов  сокрыта основная логика и суть программы. Обычно это запросы к базе данных, вычисления, транзакции и .п. 
4. Конечная суть большинства программ - это изменения в базе данных. Такие изменения лучше и проще делать делать через ORM.
Таким образом мы изолируем нашу логику от привязки к конкретной БД.
ORM позволить при желании легко сменить нашу текущую БД на другую и упростит работу с ней.
5. Важное дополнение:
RabbitMQ это всего лишь способ передачи данных, дополнительная точка ввода данных в программу подобно HTTP запросу.
Ее обработка не должна выделяться из общей архитектуры. Ее логика сокрыта за событиями и реализуется в методах класса.
// EN
1. First, we need a data entry point for the program, in our case, it is HTTP requests.
The job of an entry point is to accept and convert input data into the application's internal data format.
It is important to note that the application should not depend on the entry point.
If necessary, it should be easy to change the input source from HTTP requests to CLI or even Bluetooth.
Next, the entry point passes control to a predefined event.
An event is a set of logical "business" actions, such as logging, analytics, sending notifications, or targeted actions.
Classes reflect the capabilities of the business, such as ordering a taxi, searching for free cars, or calculating the cost.
Inside its methods, the main logic and essence of the program are hidden.
This typically includes database queries, calculations, and transactions.
The end point of most programs is database changes.
These changes are best and easiest to do through an Object-Relational Mapping (ORM) framework.
This isolates the logic from binding to a specific database
and makes it easy to change the current database to another one if needed.
In addition, RabbitMQ is another way to pass data,
it acts as an additional data entry point to the program,
similar to an HTTP request.
Its processing should not stand out from the overall architecture and its logic should be hidden behind events
and implemented in class methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment