Search⌘ K
AI Features

The Comment Class

Explore how to enhance a social media app by adding a Comment class that supports dialogue on posts. Understand composition and encapsulation by linking comments to users and posts, and learn to extend functionality for threaded replies.

Chirpy is coming together nicely. So far, users have created posts and liked them. Let’s see the list of tasks that Chirpy can do so far!

  • Add a user.

  • Post a chirp.

  • Like a chirp.

But what about the conversation that follows a chirp?

Social media isn’t just about posting and liking—it’s about dialogue.

Today, we’ll add that conversational element by introducing a Comment class. ...

How would you integrate comments into the Post class?

Now that you’ve identified the problem and are heading in the right direction toward a solution, let’s take the next step and start building the Comment class to bring conversations to life on Chirpy! 

The Comment class

The idea is simple: each comment will have text and an associated commenter (a user). This demonstrates composition in that a comment is built by ...