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

Review: Voting Challenge #58

Closed
wants to merge 2 commits into from
Closed

Review: Voting Challenge #58

wants to merge 2 commits into from

Conversation

ajfumero8
Copy link

@ajfumero8 ajfumero8 commented Jan 12, 2025


name: Solution Review Challenge 1
about: A template PR for code review with a checklist

For Voting age challenge

This code should be able to state and verify a voter's age and compare it to a set voting age in order to return a value containing the voter's name and if they are old enough to vote

Code should also ask for Input for the specific voter's name and be able to return a correct value based on name

This code should use min_age and a defined can_vote functions in order to state and verify ages of all the listed voters

It should also set the ages of the voters with their:

  1. Name
  2. Age

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
  • The function has correct type annotations
  • The function is not called in the function file

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 the documentation
  • 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
  • The code includes defensive assertions
  • Defensive assertions include as little logic as possible

@ajfumero8 ajfumero8 self-assigned this Jan 12, 2025
@ajfumero8 ajfumero8 changed the title Uploading Voting Challenge Review: Voting Challenge Jan 12, 2025
@ajfumero8 ajfumero8 closed this Jan 12, 2025
@ajfumero8 ajfumero8 deleted the ajfumero8-patch-17 branch January 12, 2025 22:38
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