DEV Community


Posted on

Terminal game that generates golf drills

Hi everyone, first time poster here. I am currently working my way through a pro series on Codecademy and just finished up my first "portfolio project." Any critiques (or supportive comments) would be appreciated. Also let me know if I am botching this blog post. Including the code here felt a little weird, but if that is cool to do, let me know.

The program I created generates a golf drill for the user to implement in their own practice. I am a big golfer myself and I thought it would be fun to create something that gives a drill based on what the user wants to work on and how good they are. A little bit of golf knowledge is required to know what is going on. If you understand what a golf handicap is and the basic skill areas of the game, you should be good to go! I included a limited number of drills because I didn't want to go all out on the project, but a couple options gives a good sense of what is going on.

Here is a link to the code in GitHub and attached is a photo of the program in action.

Image description

Discussion (4)

wmansfieldgolf profile image
wmansfieldgolf Author

Oh okay, thanks!

I appreciate it. I'd love more of a code review and general suggestions I think. I don't particularly care about the project but if you have any specific thoughts on it already, I'd take those too. I am more interested in how to write better code than in creating a better project at this point. I can worry more about that later when I have some more technical ability.

Thanks for taking the time to respond and provide some feedback!

wmansfieldgolf profile image
wmansfieldgolf Author • Edited on

This looks like great stuff! I will review later today or tomorrow and circle back with any questions. Thanks for the feedback!


Ok, I love the feedback. Thanks so much. Just some thoughts on what you gave me below:

Future Improvements

I really liked what you mentioned in this section but as of now, I have no idea how to do anything like that.

  • Adding web based UI. This sounds super cool. Is there a direction you can point me so I can start learning more about this? Is this like learning CSS and HTML and learning how to incorporate them with Python?
  • Storing user data and running analytics... showing skills for database communications. This (I think) is the next thing on my plate over at Codecademy. Starting to dig into "CS102: Data Structures and Algorithms." So perhaps I will learn more in the coming weeks.

Code Review

Quick hits

I figured the Skill class was kind of pointless but the project suggested I try to look for something I could make into a class for the practice.

Absolutely right on the double vs single quote. I need to make up my mind. Do you think there is a certain advantage to one vs the other?

Logical reordering - I think this is something that will come with more time and experience? Having a better sense of the basics and knowing I can use this method or that method for whatever the situation is...

Remove Eval

So it is interesting you mention this. I was a bit stuck on this part for a while because I am using the user input to call the instance of class Skill. Maybe this is just bad practice? I cleaned the user input (e.g. "Putting " to "putting") and set it equal to the variable 'formatted_improvement'. To my knowledge (or at least my IDE wouldn't let me) I could not call the method using 'formatted_improvement.determine_drill_dict' so I did some searching and discovered I could use eval. Perhaps this goes to your point that the class would be easier to instantiate at runtime. Will mess with code and see what happens.

Change drills data... JSON + multi level dict

I totally agree with you here, those just are skills I don't have yet. Haven't learned about JSON or multi level dictionaries.

Loop control

Another area I was a little stuck and turned to the internet for a solution. I see what you are saying though. It felt a little clunky to me when I found the solution. What do you mean by an anti-pattern?


Yes! I have started to notice coming up with appropriate names for things can be tricky, especially as code gets more complex. I will check out the code and think about a way to make some of the names better and pay more attention in future projects.

This was extremely helpful to me. Thank you for taking the time to review it.