Skip to content

Creating a pull request to leave review comments for Snowman#22

Open
yangashley wants to merge 10 commits intoAda-C23:mainfrom
celestialmage:main
Open

Creating a pull request to leave review comments for Snowman#22
yangashley wants to merge 10 commits intoAda-C23:mainfrom
celestialmage:main

Conversation

@yangashley
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Author

@yangashley yangashley left a comment

Choose a reason for hiding this comment

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

Really nice work on your first project here at Ada!

Please review my comments on this pull request for feedback about your submission.

Let me know if you have any questions!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

A note about comments: Folks might find it useful to leave comments that explain what different lines/sections of code do in the beginning of their coding career. However, when we write self documenting code (code with descriptively named variables and function names) that is concise and easy to follow, then there should be no need for comments. For example, if a function is named get_letter_from_user, I can deduce what the function should do without needing to read a comment that explains what it does.

Comments add more lines of code in a codebase. More lines of code make a codebase more challenging to maintain and update and also create more areas where a bug can accidentally get introduced.

Teams have differing opinions about comments. Some teams may be ok with some comments here and there and some teams prefer no comments unless absolutely necessary. You’ll find out how your team feels when you get there!

My opinion, when it comes to reviewing your work, I prefer to not have comments because if the code is concise and clear then I should be able to understand it. In the future, I challenge you to write fewer comments and eventually remove the comments before you submit your work. If it’s challenging to understand without comments then we’ve identified areas for growth 😁

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. I include a lot of comments in my code because it helps me focus on what my code is supposed to do, but I can definitely understand how comments can muddy and bloat code files. From now on, I will remove all comments from the final versions of my repos!

game.py Outdated
"""
pass

# print(snowman_word)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Remove code that is not used and commented out. Leaving commented out code can lead to confusion when other developers come along and read code. Why is this commented out? Should I comment it back in?

Or worse, if the code gets accidentally commented in then you would have code that shouldn't execute that ends up getting run which would lead to a bug. In this case, it's a minor bug that prints a string, but if the code was something more consequential like deleting a user account then we'd be dealing with a bigger issue.

Suggested change
# print(snowman_word)

game.py Outdated
#prints a status message and adds the incorrect letter to the wrong_guesses_list
print(f"The letter '{user_letter}' is not in the word.")
wrong_guesses_list.append(user_letter)
print_snowman_graphic(len(wrong_guesses_list))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Notice that there's some repetition in your code. len(wrong_guesses_list) appears 2 times.

When we repeat our code, it makes it difficult to maintain because we need to find all the different places the repeated code appears. For example, if I wanted to change the variable name wrong_guesses_list to wrong_guesses, I'd need to look for all the places the variable I want to change appear. You could miss one and introduce a bug. Therefore, we want to keep our code DRY (Don't Repeat Yourself).

I'd prefer a variable called num_wrong_guesses declared on line 29 and then referencing that variable here on line 56 and also line 33.

num_wrong_guesses = len(wrong_guesses_list)
while num_wrong_guesses < SNOWMAN_MAX_WRONG_GUESSES and puzzle_solved is not True:: 
    # blah blah
    print_snowman_graphic(num_wrong_guesses)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I have refactored the code to include the num_wrong_guesses variable and use it in the recommended sections!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Nice work here! There is a small piece of the game logic missing. In the "Game Description" step 7 says "The game prints out all of the incorrect letters that have been guessed".

Please respond to this comment letting me know where you would add this logic that prints out all the incorrectly guessed letters and what code should you write to implement this feature @celestialmage ?

Thanks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi Ashley! In the final version of the improved code, I used the join() method to merge all of the current incorrectly guessed letters into a single string, and then printed it on line 30 with a conditional statement that only prints the list if there has been an incorrect guess so far.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Awesome, using join is what I'd do too!

game.py Outdated
# while loop with the following exit conditions:
# - the length of wrong_guesses_list equals or exceeds SNOWMAN_MAX_WRONG_GUESSES
# - the puzzle_solved boolean's state is changed to True
while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES and puzzle_solved is not True:
Copy link
Copy Markdown
Author

@yangashley yangashley Mar 3, 2025

Choose a reason for hiding this comment

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

It's more Pythonic to write:

Suggested change
while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES and puzzle_solved is not True:
while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES and not puzzle_solved:

Since puzzle_solved will evaluate to True or False, we don't need to compare it with is not.

If we wanted to check that puzzle_solved was True, we could just write something like if puzzle_solved:, but here since we want to check that it's False, we can use not to invert the value.

game.py Outdated
while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES and puzzle_solved is not True:

# print statement which calls the function that displays the current state of the snowman word
print(generate_word_progress_string(snowman_word, correct_letter_guess_statuses))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We could also use the provided helper function print_word_progress_string to print this out

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