The Comment Class

Lean how to introduce comments to your Chirpy app.

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.

Press + to interact

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

Imagine Alex posts a chirp saying, “Finally completed my first marathon! 🏃‍♂️🔥 Feeling exhausted but accomplished!”. Emma sees it and wants to respond, “That’s amazing, Alex! How long did it take you? I’ve been thinking about training for one, too!”.

Currently, there's no way of doing it except posting a chirp saying it's in response to that, but it would not be a good approach. Also, there’s no way that Alex would be able to know that Emma has responded to his chirp without going through all the chirps to see who has chirped what. We need a feature that if someone wants to respond to a chirp, that should be done within the boundaries of that chirp. To do so, we need to have comments in the Chirpy. ...