Procedural vs Declarative Programming styles

Поделиться
HTML-код
  • Опубликовано: 17 окт 2024
  • In this session we explore two different programming styles side by side: procedural vs declarative.
    While they ultimately both achieve the same result, we take a basic example and work through that to see how they compare and comment on what the advantages and potential disadvantages or trade offs each style or programming has when directly compared to each other.

Комментарии • 4

  • @ismbks
    @ismbks 5 месяцев назад +3

    the topic looked very interesting but i had to stop the video because it is unwatchable on mobile devices
    think about increasing your font size, especially if you only use 2/3 of the screen real estate in your videos

    • @watthedoodle
      @watthedoodle  5 месяцев назад +1

      Thanks for the feedback! noted. I will look into ways to improve the experience for mobile devices 👍

  • @MiroslavPopov
    @MiroslavPopov 5 месяцев назад +2

    You messed up the sort. It must be `arr.sort( (a, b) => b.age - a.age )` or, even better: ` arr.sort( (a, b) => a.age > b.age ? -1 : a.age < b.age ? 1 : 0)`.
    I'm not sure what is happening in your example.
    Another thing. `sort` is a function with a side effect. It sorts the array in place (though, it returns a ref to the same array). You should use `arr.toSorted( ... )`.
    A good try, but you should prepare better for your videos.
    Anyway, I'll put you a thumb up for efforts.

    • @watthedoodle
      @watthedoodle  5 месяцев назад

      ah yes you're correct because the function is a comparison which I didn't do. Yes thanks for the correction. Yes it's mutable and has side effects, I didn't want to tackle that in this session as I wanted to focus on the procedural vs declarative. But you're correct, it's best avoid mutations as far as possible, of course in some cases it's needed and certainly locally scoped mutations are fine.