Comment

Comment by frognumber

In this case, the problem is with a bug creeping in:

            crust: "thyn",
DRY is about avoiding this class of cut-and-paste bugs too. Or with changing a string to a token, as it should have been:

            crust: THIN
The code isn't even correct. It's mixing JavaScript and Python. I'm also not sure why you'd declare functions for each type of pizza; that's data. I'm not sure about the context, but the right way is:

    def make_pizza(crust=THIN, toppings=[], cheese=REGULAR, sauce=TOMATO)
and then in each call, to override.

    make_pepperoni_pizza()
is bad code compared to

    make_pizza(toppings=[PEPPERONI])
All of the code in this post is horrible, and has easy solutions.

I feel dumber for having read this post, and even dumber for having responded.

parent frognumber 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton