Skip to content

aworks, tests done, but may be clearly code#14

Open
mechaleth wants to merge 1 commit into
kib-courses:masterfrom
mechaleth:my_homework
Open

aworks, tests done, but may be clearly code#14
mechaleth wants to merge 1 commit into
kib-courses:masterfrom
mechaleth:my_homework

Conversation

@mechaleth
Copy link
Copy Markdown

Not so clear, but aworks

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.

Основные огрехи:

  1. Слишком много приватных полей с двумя подчеркиваниями. Почти все они могут спокойно быть protected
  2. Логика проверки значений - оооооооооооооооооооооооооооооооооочень сложная. Прям невероятно. Код можно упростить раз в 5.

Но зато сама чистота кода - норм. За аннотации - плюс в карму

Comment thread homework/patient.py
from homework import assistive


class PatientFieldsValueError(ValueError):
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.

Type, Value и Attribute errors достаточно неплохо отражают суть ошибок, здесь не нужно создавать что-то специфическое. Но за реализацию, конечно, плюсик в карму

Comment thread homework/patient.py
return set_wrapper


def get_decorator(self_value_to_get_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.

это всё-таки не декоратор, а фабрика вызываемых объектов

Comment thread homework/patient.py
logger.error(message + ":" + str(args))


def set_decorator(set_funct, self_value_to_set_name: str, logger_name: str, *set_funct_args):
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
__PHONE_SIGNIFICANT_DIGITS_NUMBER = 10
__UNIVERAL_INNER_PHONE_CODE = "8"
__RUSSIAN_PHONE_CODE = "+7"
__ALSO_RUSSIAN_PHONE_CODE = "7"
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.

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

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
# __patient_logging = PatientLoggingDescriptor()

@classmethod
def create(cls, first_name=None, last_name=None, birth_date=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
# logging.info("File %s exists" % path_to_file)
else:
# logging.info("File %s not exists" % path_to_file)
raise Exception("File not exists")
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.

слишком общий exception

Comment thread homework/patient.py
Comment on lines +409 to +410
if ".csv" not in path_to_file:
# logging.info("File %s type error" % path_to_file)
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.

.csv необязательно должно быть в названии файла

Comment thread homework/patient.py
def __inner_dict_filler(self):
patient_data_frame = pandas.read_csv(self.myfile)
for index, row in patient_data_frame.iterrows():
self.__inner_patient_list.append(Patient(first_name=row["first name"], last_name=row["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
for line in file:
if count > 0:
patient = self.patient_creation_from_bytestr(line, encoding="utf-8")
# нулевая линия - заголовок
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.

можно ее сразу пропустить при открытии файла, тогда не придется возиться с count

Comment thread homework/patient.py
def limit(self, n):
raise NotImplementedError()
def __contains__(self, item: Patient):
if type(item) is Patient:
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.

isinstance

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