Skip to content

Прибылов 6311 Л/р 2 #1

Open
AlexPrib wants to merge 3 commits intomainfrom
Lab-2-R
Open

Прибылов 6311 Л/р 2 #1
AlexPrib wants to merge 3 commits intomainfrom
Lab-2-R

Conversation

@AlexPrib
Copy link
Owner

No description provided.

@AlexPrib AlexPrib self-assigned this Oct 22, 2023
Copy link
Owner Author

@AlexPrib AlexPrib left a comment

Choose a reason for hiding this comment

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

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

  1. В файле main.py следовало бы сделать классы наследниками от общего предка.
  2. В файле point1.py следует сделать отдельные функции чтения и записи, и избавиться от захардкорженных путей.
  3. В файле point2.py так же, как в point1.py нарушается SRP.
  4. В файле point3.py повторяется функция name_for_file. Так же в файле есть бесполезная функция, и нарушается SRP
  5. В файле point4.py есть нарушения SRP и есть проблемы с логикой в коде функций


class Iter:
def __init__(self):

Copy link
Owner Author

Choose a reason for hiding this comment

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

Незначимая пустая строка

self.file_name = "dataset.csv"

def __next__(self) -> tuple:

Copy link
Owner Author

Choose a reason for hiding this comment

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

Незначимая пустая строка

if os.path.exists(self.file_name):
with open(self.file_name, "r", encoding="utf-8") as csvfile:
arr = list(csv.reader(csvfile, delimiter=","))

Copy link
Owner Author

Choose a reason for hiding this comment

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

Незначимая пустая строка


if self.counter == len(arr):
raise StopIteration

Copy link
Owner Author

Choose a reason for hiding this comment

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

Незначимая пустая строка


class YXiter:
def __init__(self):

Copy link
Owner Author

Choose a reason for hiding this comment

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

Незначимая пустая строка

"""

if os.path.exists(file_name):
with open(file_name, 'r', encoding='utf-8') as csvfile:
Copy link
Owner Author

Choose a reason for hiding this comment

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

Считывание стоит вынести в отдельную функцию


def __init__(self):
self.counter = 0
self.file_name = 'dataset.csv'
Copy link
Owner Author

Choose a reason for hiding this comment

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

Это поле класса должно быть передаваемым параметром

def __next__(self) -> tuple:

if os.path.exists(self.file_name):
with open(self.file_name, 'r', encoding='utf-8') as csvfile:
Copy link
Owner Author

Choose a reason for hiding this comment

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

Считывание с файла нужно вынести в отдельный метод

import os


def name_for_file(first_part: str, second_part: str) -> str:
Copy link
Owner Author

Choose a reason for hiding this comment

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

Функцию следовало назвать make_name_for_file, либо create_name_for_file

return int(day)


def name_for_file(first_part: str, second_part: str) -> str:
Copy link
Owner Author

Choose a reason for hiding this comment

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

Функцию следовало назвать make_name_for_file, либо create_name_for_file

Copy link

@alxmcs alxmcs left a comment

Choose a reason for hiding this comment

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

Хотя 90% комментариев это "незначимая пустая строка", в ревью есть указание на некоторые ошибки в построении/проектировании приложения, так что, думаю, ревью можно зачесть.

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