Syllabus Lesson 9 of 141 · Map the default
Map the default

Name the habits

Why it matters Approaches are about the problem; habits are about the answerer. "Add a class", "add a library", "patch the special case" turn up whatever the question was.

Take the same thirty illustrative answers. Each carries a few plain facts besides its text: how many new dependencies it adds, how many new classes, how many special cases. Label each answer with the habits it shows and count them across all thirty.

Habit: a move made regardless of the problem. Later in the course, the Ghost counts the same habits in your own solutions.

None of these habits is wrong. A cache, a class or a library is often exactly right. But when fourteen of thirty answers reach for the same move, ask whether the problem asked for it.

Recap Count the habits, then look at the answers with none: they are usually the ones that looked at the problem first.

Your turn

Write habits_of(answer), returning a set of habit names: "cache" if the lowercased text contains any of cache, caching, redis, memcached, memo; "class" if answer["classes"] > 0; "library" if answer["deps"] is not empty; "special-case" if answer["special_cases"] > 0. Write habit_counts(answers): a dict with all four habits as keys and how many answers show each. Write plain_ids(answers): the ids of answers that show none. Then set thirty_counts = habit_counts(ANSWERS) and print it with plain_ids(ANSWERS).

Spotted a problem in this lesson? Report it · Ask about this lesson

This exercise opens soon

Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.