Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Min integer Challenge #53

Merged
merged 4 commits into from
Jan 12, 2025
Merged

Min integer Challenge #53

merged 4 commits into from
Jan 12, 2025

Conversation

tamirwaleed
Copy link

@tamirwaleed tamirwaleed commented Jan 9, 2025


name: solution review
about: A template PR for code review with a checklist

Behavior

Files

  • The file name describes the function's behavior
  • There is a module docstring in the function file
  • The test file's name matches the function file name -
    /tests/test_file_name.py
  • There is a module docstring in the tests file

Unit Tests

  • The test class has a helpful name in PascalCase
  • The test class has a docstring
  • Every unit test has
    • A helpful name
    • A clear docstring
    • Only one assertion
    • There is no logic in the unit test
  • All tests pass
  • There are tests for defensive assertions
  • There are tests for boundary cases

Function Docstring

  • The function's behavior is described
  • The function's arguments are described:
    • Type
    • Purpose
    • Other assumptions (eg. if it's a number, what's the expected range?)
  • The return value is described
    • Type
    • Other assumptions are documented
  • The defensive assertions are documented using Raises:
    • Each assumption about an argument is checked with an assertion
    • Each assertion checks for only one assumption about the argument
  • Include 3 or more (passing!) doctests

The Function

  • The function's name describes it's behavior
  • The function's name matches the file name
    • It's ok to have extra helper functions if necessary, like with mergesort
  • The function has correct type annotations
  • The function is not called at the top level of the function file
    • Recursive solutions can call the function from inside the function body

Strategy

Do's

  • Variable names help to understand the strategy
  • Any comments are clear and describe the strategy
  • Lines of code are spaced to help show different stages of the strategy

Don'ts

  • The function's strategy is not described in any docstrings or tests
  • Comments explain the strategy, not the implementation
  • The function does not have more comments than code
    • If it does, consider finding a new strategy or a simpler implementation

Implementation

  • The code passes the formatting checks
  • The code passes all Ruff linting checks
  • The code has no (reasonable) Pylint errors
    • In code review, you can decide when fixing a Pylint error is helpful and
      when it's too restricting.
  • Variables are named with snake_case
  • Variable names are clear and helpful
  • The code follows the strategy as simply as possible
  • The implementation is as simple as possible given the strategy
  • There are no commented lines of code
  • There are no print statements anywhere
  • The code includes defensive assertions
  • Defensive assertions include as little logic as possible

@tamirwaleed tamirwaleed added documentation Improvements or additions to documentation Challenge This is for coding challenges labels Jan 9, 2025
@tamirwaleed
Copy link
Author

Completed the self-assigned Min Integer challenge, I've also added my learning goals to the markdown file in the collaboration directory

@tamirwaleed tamirwaleed linked an issue Jan 9, 2025 that may be closed by this pull request
@Alaa-Elgozouli Alaa-Elgozouli self-requested a review January 9, 2025 14:32
@Alaa-Elgozouli Alaa-Elgozouli self-assigned this Jan 9, 2025
Copy link

@Alaa-Elgozouli Alaa-Elgozouli left a comment

Choose a reason for hiding this comment

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

Hi Tamir, the code works well and all tests pass, however, I think there're few edits that need to be made before merging.

  • The test class name should be in PascalCase. It should be "Class TestMinInteger(unittest.TestCase)".

  • There's a small spelling mistake in line 32 in the test file. Should be "test_min_at_beginning".

  • The code is fine and has no issues, however, it does more than its description. For example, the description states that the returns need to be an int, there're tests with floats and strings, so in this case the test should raise an error instead of passing, and for this to happen, there needs to be an assertion to make sure that all elements are int so it could return an int. I'd suggest adding

Assert isinstance(element, int), "all elements must be integers"

and an assertion error if input is not int.

  • In the test file, in line 63, the return is "Brennan" which in this case does not necessarily add up to how the function works. The string with the least amount of letters is "my" and "is", however, the return is "Brennan" because it returns the least index which in this case is 1, and not actually the word with the least amount of letters, and I don't think this aligns with the main purpose of the function.

  • Since the function's name is "Min-Integer" I'd suggest making it only about integers without adding strings or floats. It would make sense to add floats incase both the return and elements statements state that they could be either int or float. However, I think it'd be better to exclude strings in this case.

Overall, the code works just fine but it does more than what the function description says. Best of luck!!

@Alaa-Elgozouli Alaa-Elgozouli added enhancement New feature or request and removed documentation Improvements or additions to documentation Challenge This is for coding challenges labels Jan 11, 2025
@tamirwaleed
Copy link
Author

Hello Alaa, I greatly appreciate the attention to details that you've put into reviewing the code.

Accordingly:

  1. I've fixed the PascalCase requirement, thus fulfilling the checklist completely.
  2. I've also fixed the spelling mistake, great catch!

As for your other suggestions, I've put them into consideration, and I agree the function does more than required. Although, this was my interpretation of the behavior, I'll definitely consider this perspective in any future challenges going forward. Truly appreciated, and if there any other suggestions please let me know. Thank you!

Copy link

@Alaa-Elgozouli Alaa-Elgozouli left a comment

Choose a reason for hiding this comment

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

All is good!!

@Alaa-Elgozouli Alaa-Elgozouli merged commit 2706532 into main Jan 12, 2025
10 checks passed
@Tbaosman Tbaosman deleted the Min-Integer branch January 12, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Min Integer
2 participants