Skip to content

[v3] Template for Exercises #305

@cstby

Description

@cstby

Rationale

As we write new concept exercises to v3, we can better set up learners for success by changing the exercise template.

Issue

Here is an example of the current template:

(defn armstrong? [num] ;; <- arglist goes here
  ;; your code goes here
)

This creates a few problems:

  • Many learners do not remove these comments before turning in their solution.
  • Learners get into the habit of writing functions without docstrings.
  • Learners are led to believe that the arglist should go on the same line as the function name. Many learners who later try to add docstrings will add them after the function arguments.

Suggestion

I propose the following changes:

  • Add a docstring below the function name. This accomplishes a few goals.
    1. Learners become aware of become aware of docstrings.
    2. The template is more representative of idiomatic Clojure.
    3. Learners are exposed to high-quality examples of how docstrings should be formatted and written.
  • Remove the single line comment referencing the function argument. Learners who get past the "function" concept will know that arguments are provided here.
  • Change "your code goes here" to be more descriptive. Something like "add function body here" or just "function body" more accurately describe what the learner needs to do.

The result woud look something like this:

(defn armstrong?
  "Returns true if `num` is an armstrong number."
  [num]
  ;; function body
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions