As we learn the principles of object-oriented programming, we might want to start refactoring our non-object-oriented code, into object-oriented code using classes. We might want to do this to increase the modularity and reusability.

Let's look at a Non-OOP example:

title = "Inception"
director = "Christopher Nolan"
rating = 91

def display_movie(title, director, rating):
    print("Movie: " + title + ", directed by " + director + ", has a rating of " + str(rating) + "% in rotten tomatoes" )
    
display_movie(title,director, rating)

Now let's see how we can write this same code as a class:

class Movie:
    def __init__ (self, title, director, rating):
        self.title = title
        self.director = director
        self.rating = rating
    
    
    def display_movie(self):
        print("Movie: " + self.title + ", directed by " + self.director + ", has a rating of " + str(self.rating) + "% in rotten tomatoes" )
                  
                              
my_movie_01 = Movie("Inception", "Christopher Nolan", 91)
my_movie_02 = Movie("Nomad Land", "Chole Zhao", 82)
my_movie_03 = Movie("No", "Pablo Larrain", 80)
    
my_movie_01.display_movie()
my_movie_02.display_movie()
my_movie_03.display_movie()

In the example above, we develop a class for the Movie. The object-oriented structure in this case gives us more flexibility to gradually expand on the data and functionality available to the program.

While it is not mandatory or necessarily always correct to utilize an Object Oriented paradigm, it is important to know the different modalities of coding available within a particular language. Some people find object-oriented programming very intuitive once they grasp the principles.

Try to experiment with what classes would you create to describe a program.

To practice, we recommend that you look into Unified Modelling Language (UML) diagrams for classes. This might be a graphic wat to understand how we can conceive of classes that interact with each other within a program.