I’ve had the good fortune to have @IsaacG mentor a few of my exercises, and call-out to him, he’s always helpful in both minor and major ways, offering small and large tips for code improvement.
More than once, however, he’s (rightly) pointed out small deficiencies in the code that stem from working with the exercise template and editing it as minimally as possible to complete the exercise.
Two examples from a recent exercise, Simple Linked List’s template:
class LinkedList:
def __init__(self, values=[]):
pass
I kept the default value, and my mentor pointed out, “Never use mutable default values!” The link expressed the rationale behind the practice and provided a good alternative.
Is this one worth editing the template for? Doing so would complicate the body of the method, and perhaps require explanation in the docs. My edit based on his feedback and the linked article was this:
def __init__(self, values=None):
if values == None:
values = []
...
Another example from the same template. His feedback (referring to EmptyListException
being defined at the end of the file:
I believe most people prefer defining classes prior to where they are used
So my edit was to place it as the first class definition in the file.
One point of view is that these are minor, perhaps even esoteric, practices (more so with the class definition order, I think). But I also see a case for giving students the best template based on known best practices for the given language. Especially since a major purpose of Exercism is not just to teach programming languages but to teach best practices within each programming language. And having the templates themselves violate some of these best practices seems counter to that goal, especially when stellar mentors correctly point out the violations.
This also might be a higher issue for Python. How many other languages express the language philosophy as import this
does? So I’m not sure how specific this issue is to Python (which I’m currently spending my time on) as opposed to other languages.
So my question becomes, as template violations of best practices are revealed to me, should I attempt to edit the template files in the repository to better conform to the best practices?