Skip to content

BACK-END COVID-19 PYTHON#18

Open
ispaneli wants to merge 4 commits into
kib-courses:masterfrom
ispaneli:master
Open

BACK-END COVID-19 PYTHON#18
ispaneli wants to merge 4 commits into
kib-courses:masterfrom
ispaneli:master

Conversation

@ispaneli
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Collaborator

@romvano romvano left a comment

Choose a reason for hiding this comment

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

Код хороший, но часто перегружен такими нюансами, как, например, преобразование True/False/None к текстовым полям и обратно. С точки зрения оптимизации, это экономия на спичках. С точки зрения поддерживаемости кода - становится сильно сложнее

Comment thread homework/check.py


def check_first_name(first_name):
if isinstance(first_name, str):
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.

лучше наоборот: if not isinstance: raise, а дальше просто логику, чтобы не плодить вложенность

Comment thread homework/check.py
if first_name.isalpha():
first_name = first_name.capitalize()

page = requests.get(f"http://imenator.ru/search/?text={first_name}")
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 homework/check.py

def check_phone(phone):
if not isinstance(phone, str):
if 10_000_000_000 <= phone <= 99_999_999_999:
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.

а если phone не число, не залогируется ошибка

Comment thread homework/patient.py


class Patient:
_DOCUMENT_TYPES = {None: "Паспорт РФ",
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 homework/patient.py
@document_type.getter
def document_type(self):
"""Для оптимизации кода тип документа
храним как None, True или False.
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 homework/patient.py

if check.is_typo_in_name(self._last_name, new_last_name):
INFO_LOG.info(f"Изменена фамилия на '{new_last_name}' у пациента {self}.")
self._last_name = new_last_name
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 homework/patient.py

if check.is_typo_in_name(self._first_name, new_first_name):
INFO_LOG.info(f"Изменено имя на '{new_first_name}' у пациента {self}.")
self._first_name = new_first_name
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 homework/patient.py
for i, line in enumerate(f):
if i != 0:
if i <= last:
params = line.decode().split(',')
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.

можно же не в байтовом режиме файл открыть

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.

2 participants