Social Network

Level: Intermediate 30–60 min

Concepts: State

Solutions: C# | TypeScript | Python


Implement a console-based social networking application that satisfies the scenarios listed below. The application must use the console for input and output.

Users submit commands to the application. Commands always start with the user’s name.

Do not worry about handling any exceptions or invalid commands. Assume the user will always type the correct command.

Do not make it work over a network or across processes, do it all in memory assuming users are on the same terminal.

Non-existing users should be created as they post their first message. The application should not start with a predefined list of users.

Scenarios

Posting Alice can publish messages to a personal timeline. > Alice /post What a wonderfully sunny day!

Reading Bob can view Alice’s timeline. > Bob /timeline Alice

Following Charlie can subscribe to Alice’s timeline and view an aggregate list of all subscriptions. > Charlie /follow Alice

Wall Charlie can view an aggregate list of all the people he has subscribed to follow. > Charlie /wall

Note: If Charlie follows Alice and Bob he will see a time sequenced list of post from both of them on his wall. That is to say the post are displayed with the most recent at the top.

Bonus

Mentions Bob can link to Charlie in a message using ’@’. > Bob /post @Charlie what are your plans tonight?

Note: this is not a new command, just an expansion of how the /post command works. Any mentions should appear on a user’s wall even if they do not follow the user.

Direct Messages Mallory can send a private message to Alice. > Mallory /send_message Alice

Alice can view all private messages. > Alice /view_messages

Reference Walkthrough

Full C#, TypeScript, and Python implementations live at tddbuddy-reference-katas/social-network with the same eighteen scenarios across all three languages, a fluent NetworkBuilder, and a Clock collaborator so tests control timestamps deterministically.

The key design distinction is timeline vs wall: timeline shows only a user’s own posts (reverse chronological), while wall shows the user’s posts plus posts from everyone they follow (reverse chronological across all authors). Both are pure queries over the post list — no side effects.


  • The Test Pyramid Was an Economic Argument
    The test pyramid was not a quality law. It was a cost structure: unit tests were cheap, integration tests were expensive, so you wrote many of the first and few of the second. Agents collapsed the cost of writing tests at every level, and the cheapest test that still tells the truth is the one that pins a seam the agent cannot fake.
  • Agents Amplify Whatever Vocabulary They Find
    Agents do not bring vocabulary to your codebase. They mirror what's already there. Strong vocabulary gets agent contributions that read like the team. Weak vocabulary gets faster mediocrity. The work you did for craft reasons just became leverage.
  • The Hidden Output of TDD Was Never Code
    The visible artifact of TDD is a passing test suite. The actual artifact, the one that compounded value over the life of the codebase, was the vocabulary the team built while writing it. The dictionary, not the regression net.