Coffee & Code: Good Coding Practices (Sara Sjunnebo)

Поділитися
Вставка
  • Опубліковано 22 жов 2024

КОМЕНТАРІ • 2

  • @MaybeJustJames
    @MaybeJustJames 4 роки тому +1

    In the section "Using Conditionals" Sara argues that the second version, "is a lot easier to follow the logic". This does not seem justified given the programmer still has to keep track of up to 5 conditionals and separate `else` handling. I suppose this is supposed to be pseudocode but it obscures the point Sara is trying to make. It would be nice to show a 3rd version which handles each case independently (with e.g. an early return).

    • @sarasjunnebo6513
      @sarasjunnebo6513 4 роки тому +1

      Hi James,
      Thanks for watching!
      Yes, I agree that the example could be clearer! I took this example more or less directly from the book and the main point was to show what happens when you make the expected case the main thread through the conditionals and put it after the if statement instead of the else statement. But of course there are many other things that should be considered when using conditionals, and the book does bring up quite a lot of them. There just wasn’t time to go through them all :)