A visual guide to why DECLARATIVE code is better

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

КОМЕНТАРІ • 40

  • @JoshuaMorony
    @JoshuaMorony  3 місяці тому +3

    Extra content around 3D scenes and cameras for Angular apps going out in the newsletter tomorrow: mobirony.ck.page/4a331b9076

  • @tarquin161234
    @tarquin161234 3 місяці тому +28

    I am the only reactive programmer in my team. They have asked me to do a presentation explaining why declarative is better. I think I will start off with this vid. Thanks!

    • @larrycoleman8149
      @larrycoleman8149 3 місяці тому +3

      Must be nice. My team used to block my declarative code during code review. Such a pain. Share your secret to push declarative code😂

  • @vivmaniaa
    @vivmaniaa 3 місяці тому +2

    Hi Joshua, you do not know how much I've been struggling to understand what are both of them, this video really resolved my confusion. I thank you with respect and love from the bottom of my heart❤

  • @gcancino
    @gcancino 3 місяці тому +13

    A simple code to understand it better would be great.

  • @itzmeys
    @itzmeys 3 місяці тому +2

    Love this video as a visual learner, please make more videos like this! It really helps visual learner like me to understand and learn so much better.

  • @jaypatel-dt8bw
    @jaypatel-dt8bw 3 місяці тому +6

    Kudos to your grate efforts for Angular community....

  • @br3nto
    @br3nto 3 місяці тому

    Awesome vid and explanation. It drives me nuts seeing the type of code that you describe as imperative, for exactly the reasons you describe. I think there is a lack of resources showing/teaching people alternatives.

  • @samantwi1313
    @samantwi1313 3 місяці тому +1

    I bought your course, Its Brilliant

  • @shaylevinzon540
    @shaylevinzon540 3 місяці тому

    That's a cool representation of those concepts. People are so afraid of curry/pipe functions they just never attempt to use it, maybe your next diagrams could explain this process the functions go through.

  • @MeadAlsorani
    @MeadAlsorani 2 місяці тому +1

    Honestly, this is the first time I understand the real and the specific meaning of "Declarative" and "imperative", thanks a lot

  • @jeffnikelson5824
    @jeffnikelson5824 3 місяці тому +1

    totally on your side when it comes to declarative vs imperative code.
    looking back at the past I would even say that an imperative approach is much more prone to errors than a declarative one. In my current project, I have had the experience that a more declarative approach just forces the developer more to think about error states ahead of time in comparison to an imperative implementation which overall resulted in a more robust implementation

  • @TayambaMwanza
    @TayambaMwanza 3 місяці тому

    Very nice and simple explanation.

  • @olegsubik
    @olegsubik 3 місяці тому

    Makes total sense!

  • @msacket
    @msacket 3 місяці тому

    Great explaination!

  • @wahoobeans
    @wahoobeans Місяць тому

    I think easiest explanation is… have you ever worked with a large excel workbook? Yes? Typically there’s a main tab with variable values defined. Update those variables and then the rest of the workbook is updated accordingly everywhere else. It’s the same thing with frontend code.

  • @iligol3
    @iligol3 3 місяці тому +4

    Although I am completely on your side in this matter, the explanation is very abstract, understandable mostly to those who already use it. I don't understand how this video will encourage a user of the imperative approach to try to apply the declarative approach without some code example.

    • @JoshuaMorony
      @JoshuaMorony  3 місяці тому +2

      Whether it's effective or not I don't know, but my goal was to be abstract here. I have a lot of code focused explanations in videos and I feel like the point often gets lost because people think the declarative code is harder/overly complex and it's *easier* to just write imperative code. My goal here was just to explain conceptually why declarative code is actually easier, without getting lost in the details, and then if people can be convinced of that they can then move on to the how (even though at a small scale the declarative approach might seem harder/unnecessarily complex)

    • @Cheesyonmytoasty
      @Cheesyonmytoasty 3 місяці тому +1

      Same, I found this way too abstract.

    • @NehalHasnayeen
      @NehalHasnayeen 3 місяці тому

      well it made sense to me and encouraged me to keep it in mind from now on about declarative approach when coding

  • @vorant94
    @vorant94 3 місяці тому

    What is your opinion on stuff like effects? They seem to bring declaration fragmentation into reactive code… like now you have your variable declaration with some logic, but this variable can also be changed inside effects hence bringing back jumping between variable usage places

    • @JoshuaMorony
      @JoshuaMorony  3 місяці тому

      Generally I will use effects for side effects that don't affect the data flow in the application, things like triggering a save or playing a sound or playing a video. Although I generally avoid it I do still on occasion use effects that affect the data flow in the application, but in these cases I still won't be reassigning values I would have the effect trigger some source which other declarations would then react to.

  • @richardholguin3481
    @richardholguin3481 3 місяці тому

    Great content

  • @_Greenflag_
    @_Greenflag_ 3 місяці тому +1

    what would you recommand as library(ies) for declarative code outside of Angular?

    • @aravindmuthu5748
      @aravindmuthu5748 3 місяці тому +1

      rxjs...

    • @ИвоСпасов-й5ш
      @ИвоСпасов-й5ш 3 місяці тому

      Simple rxjs, you don't need anything more. RxJS also will allow you to carry out complex data flow processing that is based on array functionalities like filter, map and so on, as well as rxjs specific operators. This is beneficial when you need to provide multicasting (multiple components can "subscribe" to your reactive source), and again when you need to do complex manipulations on your data stream. If you need something more simple and restricted, then use one of the angular's newer features - signals. You can still observe the way a value changes, but at the cost of making simpler data manipulations and having only one "subscriber".

  • @adamlawrence3651
    @adamlawrence3651 3 місяці тому

    Fighting the fight in a large enterprise app. the real pain I find is when the 2 approaches meet 🤢. For example a non serializable class going into an ngrx store, and things being mutated sometimes despite being in a store. the app was originally written in angular 2, so it's easy to see how it's happened. but now it's my job to unf**k it 😅.
    I could still see value in imperative to knock out an admin portal quickly for example. but once you go reactive/declarative you never go back.

  • @MrDrogoyonk
    @MrDrogoyonk 3 місяці тому +3

    what are the difference between reactivity and declarative?

    • @JoshuaMorony
      @JoshuaMorony  3 місяці тому +9

      You can't have a declarative application (at least one that does anything) without reactivity. Reactivity is another one of those things people disagree on the definition of, but the simplest way to think of it imo is that reactivity enables declarative code by allowing declarations to react to changes. Take the "isHot" example, that is declarative and to be declarative it needs the ability to "react" to "temp" changing - that is the reactivity part.

    • @MrDrogoyonk
      @MrDrogoyonk 3 місяці тому

      @@JoshuaMorony thanks for your answer!!

  • @zero14111990
    @zero14111990 3 місяці тому

    this is what i have to read in the actual project im working 😭 is a big codebase and the client do not want to give us the total codebase to be able to implement new modules that they pay us to do 🙃

  • @KatJay-i9y
    @KatJay-i9y 3 місяці тому

    animations are out of this world, can anyone tell me wt kind of tool or software was used?

    • @JoshuaMorony
      @JoshuaMorony  3 місяці тому +1

      I'm using Motion Canvas, which lets you create animations with TypeScript/JSX

  • @motbus3
    @motbus3 Місяць тому

    For such bold remarks, presenting with boxes is quite biased

  • @TayambaMwanza
    @TayambaMwanza 3 місяці тому +3

    Maybe people tend to do imperative code, because declarative code forces you to consider most of the links in your code upfront.
    Imperative at first glance makes you feel like there's less links, so while you're writing it feels easier but the reality is you will have to do the work of linking your code over and over again when you read it.

    • @JoshuaMorony
      @JoshuaMorony  3 місяці тому +1

      Yes I think this is exactly it

    • @rkokie
      @rkokie 3 місяці тому

      I have been stuck in imperative code for a long time, mainly due to the fact I had a hard time really understanding the mental map for declarative with RxJS. Thanks for your teachings Josh!

  • @tranquillityEnthusiast
    @tranquillityEnthusiast 3 місяці тому

    Rxjs everywhere everywhere 😅😅😢

  • @message59
    @message59 3 місяці тому +1

    thanks again joshua for all the effort and thoughts you put in your videos it helped me so much grasping concepts and find my way through all this (sometimes complicated) stuff
    you are the man 🫡👍🏻