#100DaysOfCode: Python Day 16

#100DaysOfCode: Python Day 16

Object Oriented Programming

#100DaysOfCode Day 16

☕️ I CREATED MY OWN OOP COFFEE MACHINE! ☕️
CLICK HERE and press "Run" to try it out.

Screenshot 2021-05-26 at 23.34.38.png

Yesterday I solidified my knowledge of Object Oriented Programming. Thanks to this course for teaching me how to explain these concepts at a lower level again. Now things are getting a lot more fun. I struggled a lot with Visual Studio Code as I am used to using Visual Studio Professional at work. I prefer PyCharm, which is a fully-fledged IDE.

The below image from this medium article is fantastic to use to explain OOP. OOP.png

Think of a class as a blueprint for how an object may operate.
In our case, this is a Pokemon

Think of an object as an item that belongs to a category which is the class. Pikachu was created from the Pokemon class because Pikachu is categorised as a Pokemon.

Think of attributes as values (pieces of information) that belong to that object and are common across all Pokemon.

Lastly, think of methods as functions (actions) that the object can do and are common across all Pokemon.

Lessons

  1. Use proper IDE's that take the repetitive setup out of things, and the best part about using PyCharm is that it can spellcheck 😁.
  2. Knowing how to explain concepts like OOP is a valuable skill. Communication in a team is everything.
  3. pypi.org is a package index where we can search for a find packages

TO THE CODE!!!

from turtle import Screen, Turtle

# We create timmy the object from the turtle class
timmy = Turtle()
print(timmy)
# Below we access methods of the turtle
timmy.shape("turtle")
timmy.color("DeepSkyBlue")
timmy.forward(100)

# canvheight is a attribute screen
my_screen = Screen()
print(my_screen.canvheight)
# OUTPUT
# 300

# exitonclick() is a method
my_screen.exitonclick()
# Read more about what you can do with this library: https://docs.python.org/3/library/turtle.html

I always wanted to use more of the correct programming terminology in my workplace, and doing this course is helping me do so. You know-how at work we all follow "agile", yeah, we follow best practices and standards just as well. Knowledge is power, but consistency is key!

Want to stay up to date with my learning journey? Just sign up for my newsletter.