...

/

Inheritance—Creating a VerifiedUser

Inheritance—Creating a VerifiedUser

Learn what inheritance is and how we can use it in Chirpy.

Right now, all users on Chirpy are the same—whether they are regular users or verified ones. But just like in real-world social networks, some users need to stand out. Verified users bring credibility and recognition to the platform, making their presence more distinct.

To reflect this, Chirpy also recognizes verified users, giving them:

  • A verification badge to indicate their authenticity.

  • Special privileges—perhaps their posts appear more prominently.

Now, we could solve this problem by adding an extra attribute like is_verified to our User class, but this approach comes with some major drawbacks.

Take a moment to reflect: What potential drawbacks might arise from this approach? Jot down your ideas in the widget below.

What potential problems might we face if we choose to add an extra attribute like is_verified directly to our User class to distinguish verified users from regular users?

Clearly, we need a better way to structure our code so that verified users can have their own unique attributes and behaviors without affecting regular users.

Instead of modifying the User class, we’ll create a VerifiedUser class that inherits from User.

Inheritance is an ...