Skip to content

Group 2#20

Open
PtrBld wants to merge 1 commit intomainfrom
new_branch
Open

Group 2#20
PtrBld wants to merge 1 commit intomainfrom
new_branch

Conversation

@PtrBld
Copy link
Copy Markdown

@PtrBld PtrBld commented Nov 23, 2023

No description provided.

Comment thread library/model/book.py
Comment on lines +11 to +12
due_date: datetime
weekly_fee: float
Copy link
Copy Markdown
Collaborator

@NumericalMax NumericalMax Nov 23, 2023

Choose a reason for hiding this comment

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

Unused variable. You might want to shift the variables into the __init__ method. With doing so, the referencing using self. throughout the class, e.g., in the borrow_book function should work.

Copy link
Copy Markdown
Collaborator

@NumericalMax NumericalMax Nov 23, 2023

Choose a reason for hiding this comment

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

Consider separation of concerns. The book class represents a collection of books, while a due_data variable is associated with a unique copy of a book. Similarly logic applies to the weekly_fee.

Comment thread library/model/book.py
return book

def can_borrow(self) -> bool:
if self._book_type == "Paper":
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.

You could consider creating new classes for the different types of books, which all inherit from an abstract book class.

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.

This would also reduce the number of parameters for the constructor of your objects, since not all variables are necessary for the different types of books

Comment thread library/model/book.py

class BookSerializer:
def serialize(self, book: Book, format: str):
def serialize(self, format: 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.

Separation of concerns.

Comment thread library/model/user.py
reading_credits: int = 0

def __init__(self, email, firstname, lastname, mob1, mob2, area_code, landline, country_code):
def __init__(self, email: str, firstname: str, lastname: str, mob1: str, mob2: str, area_code: 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.

You could put the information on telephone availability into a separate TelephoneInformation DTO class.

Comment thread library/payment/paypal.py
PAYPAL_DATA_BASE: dict[str, str] = {"amanda1985": "PaSsW0rD", "qwerty": "123456789"}
PAYPAL_ACCOUNT_BALANCE: dict[str, float] = {"amanda1985": 100.0, "qwerty": 42.0}

class Paypal:
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.

This a nice abstraction and aligns with the existing CreditCard class

You could consider creating a parent class (e.g. PaymentMethod) and using inheritance.

raise ValueError("Payment information is not set or not valid")
fee, reading_credits = self.calculate_fee(self.customer)
is_paid: bool = self._pay_with_credit_card(card, fee)
if isinstance(pay_method, CreditCard):
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.

You could use the actual CreditCard and PayPal classes to process the invoices instead of doing an isInstance check.

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.

4 participants