Guido's Gorgeous Lasagna: Remove instruction to create PREPARATION_TIME constant and rewording instructions

Hello Exercism community :wave:

I found the suggestion in Guido’s Gorgeous Lasagna to use a PREPARATION_TIME constant confusing and can’t figure out how you could do this within the context of the problem, so I think it should be removed.

Also, for the elapsed_time_in_minutes() function, it says:

This function should return the total number of minutes you have been cooking, or the sum of your preparation time and the time the lasagna has already spent baking in the oven.

I think “cooking” should be changed to “working” since cooking implies the amount of time that lasagna has been in the oven, but we want to refer to preparation + cooking time.

Hello - welcome :slight_smile:

Could you explain what you found confusing about it? What was your solution? Did you use the EXPECTED_BAKE_TIME constant? Was that clearer?

Maybe “the total number of minutes since you started working on the lasagna”?

I do think the second half of the sentence makes it quite clear though, so maintainers might not want to change this.

Hi @ebanner :wave:

(Python track maintainer here). Welcome to the Exercism forums. :slightly_smiling_face:

Constants in Python aren’t really constants in the way final variables are in Java, or const variables are in Go.

Python’s mutable/dynamic to a fault, so a “constant” ends up as a strong convention of capitalizing the variable name, rather than something enforced by a keyword, compiler, or runtime. This can be a bit of a setup/foot-gun for those learning the language.

Constants are typically declared outside any class or function declaration (so they’re visible globally within the program), at the top of the code file or in helper files that are imported.

Because “constants” are a convention it’s really important to have this first exercise help students practice and get used to the formatting and terminology.

We did have some language about scope for constants in a previous version of this exercises introduction, but we removed it because it was creating confusion. Instead, we edited the stub file with a note of where to declare the variables.

All that being said, if you (as Jeremey asked above) could give us some detail around what was unclear/confusing in either the introduction or stub comments, with your suggestions for clarifying — that would be really helpful. :slightly_smiling_face:



Both the Oxford English Dictionary and the Merriam-Webster dictionaries define cooking as

The practice or skill of preparing food by combining, mixing, and heating ingredients

food that has been prepared in a particular way

.

And as Jeremey has said above, the remainder of the sentence goes on to clarify that this total is made up of prep time and baking time — so I’m not inclined to change the wording at this time.

Could you explain what you found confusing about it?

The thing I find confusing is I don’t know what PREPARATION_TIME should refer to nor what to set it to.

What was your solution?

(omitting the docstring):

def preparation_time_in_minutes(number_of_layers):
    result = number_of_layers * 2
    return result

def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
    result = preparation_time_in_minutes(number_of_layers) + elapsed_bake_time
    return result

Did you use the EXPECTED_BAKE_TIME constant? Was that clearer?

Yes, I used EXPECTED_BAKE_TIME - that was very clear from the instructions (set it to 40).

the remainder of the sentence goes on to clarify that this total is made up of prep time and baking time

The way I experienced the question for the first time is it was asking for two contradictory things (or two different things?), not a clarification. I just assumed to take the second thing that was being asked because that made the most sense.

If we don’t change the language, I’d recommend switching to saying “i.e.” or “That is” instead of “or”:

This function should return the total number of minutes you have been cooking. That is, the sum of your preparation time and the time the lasagna has already spent baking in the oven.

or

This function should return the total number of minutes you have been cooking i.e. the sum of your preparation time and the time the lasagna has already spent baking in the oven.

Looking back, I realize I’m conflating “cooking” with “baking” (the first question uses baking).

By the way, how do you quote a snippet from someone?

Select the text and click the “Quote” that pops up :slight_smile:

Oh nice! Thank you!

The answer to those questions is “the amount of time to prepare a single layer” and “2”. Does that make sense now that you’ve solved it?.

@BethanyG we had similar issues at the JavaScript track so we stopped expecting PREPARATION_TIME to be exported and instead added a note for mentors to discuss Magic Numbers instead.

This sounds like a good change.

As an alternative, how do you feel about the language in the JavaScript track?

1 Like

I will take a think on the language this week. But I’m not interested in accepting a PR for it. My current rephrasing/thinking is below.


4. Calculate total elapsed time (prepping + baking) in minutes

Define the elapsed_time_in_minutes() function that takes two parameters as arguments:

  • number_of_layers (the number of layers added to the lasagna)
  • elapsed_bake_time (the number of minutes the lasagna has spent baking in the oven already).

This function should return the total minutes you have been in the kitchen cooking — your preparation time layering + the time the lasagna has spent baking in the oven.


We don’t test that the students define PREPARATION_TIME — solutions will pass without it. We do have a note in the stub, but it doesn’t cite magic numbers.

I was going to add a note about magic numbers here in the thread and forgot. :slightly_smiling_face:

We could add mentor guidance for the exercise - although concept exercises aren’t really supposed to be mentored, since they’re much more targeted than the practice exercises.

I’ll take a think on whether we add a note for mentors … or maybe a clearer directive & link in the stub, rather than the existing “suggestion”.

Currently, I am leaning toward a note & link in the stub, and/or a note in the instructions.

1 Like

I mentor this exercise pretty frequently :grin: (and I often mention magic numbers)

2 Likes

Mentoring notes added to discuss magic numbers: Add mentoring notes for python/guidos-gorgeous-lasagna by IsaacG · Pull Request #2378 · exercism/website-copy · GitHub

2 Likes

(This was discussed briefly over on discord to prevent response slop here. Thank you for starting this conversation @ebanner)

Ah, I see. Yes, it does.

Something like PREPARATION_TIME_PER_LAYER would be clearer.

I like the PREPARATION_MINUTES_PER_LAYER naming :ok_hand:

Where in the discord was this discussed? I don’t see it (is there a hidden channel?)

Yup. In the maintainer channel. Bethany and I discussed my adding some mentor notes around this. The PR is the result of that discussion.

Oh, I’m guessing the maintainer channel is private?

Hm, which PR are you referring to?

See a couple of posts up ;) That links to this PR.

Yes. It’s only accessible to maintainers.

Oh nice, thanks!

I know I didn’t create the PR, but since my question led to the PR, could I get some reputation points? I don’t know how reputation works (is it automated or manual?), but my goal is to become a mentor here, so I’m working towards that.

1 Like