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

Scissors - Araceli M. #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

aracelim1234
Copy link

No description provided.

@aracelim1234 aracelim1234 changed the title Project 1: viewing party (Scissors - Araceli M.) Scissors - Araceli M. Mar 29, 2021
Copy link

@jmaddox19 jmaddox19 left a comment

Choose a reason for hiding this comment

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

Overall, the code is well-written and readable. You demonstrated that you can write code that can work well with lists and dictionaries. You also gave yourself an opportunity to practice writing code to handle exception handling!

For the most part the code to handle nested data structures looks great as well, but there is one bug related to nested data structures in get_rec_from_favorites. See my comment below for more details.

There are also several instances where I wonder if you forgot the check what the README said the function was meant to do and instead relied solely on the unit tests. This demonstrates that you have gotten really good at reading unit tests already, which is great! However, the goal is that the functions are written to satisfy the requirements in the README and pass the tests.


if len(user_data["watched"]) == 0:
user_data["watched"] = user_data["watchlist"]
user_data["watchlist"] = []

Choose a reason for hiding this comment

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

This will introduce a bug when the watchlist contains more than one item because it will completely clear the list every time.


def watch_movie(user_data, movie):

movie_to_watch = {

Choose a reason for hiding this comment

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

The intention is that the movie we are trying to watch is passed in through the movie parameter.
There is not a situation where we ask that the function should "watch" a hardcoded movie like this.

user_data["watchlist"].append(movie)
return user_data

def watch_movie(user_data, movie):

Choose a reason for hiding this comment

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

It looks like this function was cleverly written to pass the tests, but doesn't solve the requirements listed in the README.
I'm curious to talk with you about what your process for solving this was.

Comment on lines +57 to +60
try:
average_rating = sum(rating_list) / len(rating_list)
except ZeroDivisionError:
return 0.0

Choose a reason for hiding this comment

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

Great job handling the exception!

Comment on lines +100 to +103
elif user_data["watched"][x] in user_data["friends"][0]["watched"]:
continue
elif user_data["watched"][x] in user_data["friends"][1]["watched"]:
continue

Choose a reason for hiding this comment

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

This works for the tests we provided, but only because the tests don't cover a case where the user has 1 friend or more than 2 friends.
In the future, in addition to passing the tests, I encourage you to think of what other cases might exist and if you can write code to handle those additional cases as well.

movie_list = []
friends_unique_movie_list = []

for i in range(len(user_data["friends"])):

Choose a reason for hiding this comment

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

This is a great example of writing code that can handle any number of friends! (in contrast with the code in get_unique_watched above.

Comment on lines +119 to +120
else:
continue

Choose a reason for hiding this comment

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

There's nothing wrong with having these two lines here but I want to note that the function would do exactly the same thing without them

if user_data["watched"]:
for i in range(len(user_data["friends"])):
for j in range(len(user_data["friends"][i]["watched"])):
if user_data["friends"][i]["watched"][j]["genre"] == "Intrigue":

Choose a reason for hiding this comment

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

This is another example where the code only works because of how limited the test cases are.
The requirement in the README is that the genre should match the user's most frequently watched genre, not that it should always be "Intrigue"

Comment on lines +167 to +168
for k in range(len(user_data["friends"][j])):
if user_data["favorites"][i] in user_data["friends"][k]["watched"]:

Choose a reason for hiding this comment

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

There is some funkiness happening here that the tests would catch if they were more thorough.
user_data["friends"][j] is a hash so this loop is running a certain number of times based on how many key/value pairs are in that hash, which doesn't seem to be what the code is intended to do.

Choose a reason for hiding this comment

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

This confusion generally happens less when writing loops without indexes. For example, for friend in user_data["friends"]

else:
continue

for x in movie_list:

Choose a reason for hiding this comment

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

In cases like this, I'd recommend naming variables like this as movie to be more clear and meaningful.

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