Tiny Refactors Make a Big Difference - Laracasts

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ย. 2024

ความคิดเห็น • 36

  • @renwar
    @renwar 2 ปีที่แล้ว +11

    I am usually having a feeling of "over" refactoring.
    But seeing you doing the same as mine, is a relieving...
    Thanks for making such videos..

  • @TimothySmithDev
    @TimothySmithDev 2 ปีที่แล้ว +5

    Great video, I'm a senior developer and I still enjoyed watching.

  • @jamesrogers2680
    @jamesrogers2680 ปีที่แล้ว

    Very helpful video; the thought process of your refactor was great to hear. Often coding videos are missing the "why" of decisions. Much appreciated!

  • @lucasj.pereira4912
    @lucasj.pereira4912 2 ปีที่แล้ว +3

    I feel like I would stop at 16:59, code seems more readable for me, but it's just personal preference. I don't like to inline arrays that much and 'mess' with de indentation. Not saying its a bad video, it is awesome, just my personal preference. Thanks Jeffrey!

    • @Laracastsofficial
      @Laracastsofficial  2 ปีที่แล้ว +1

      It's whatever looks prettier. Sometimes, that's inlining the array. Other times, I'd rather keep the variable.

  • @VadimBesedin
    @VadimBesedin 2 ปีที่แล้ว

    Nice refactoring. I like this gradual refactoring style - very clear. Thank you.

  • @aissa.bouguern
    @aissa.bouguern 2 ปีที่แล้ว +2

    I really enjoyed to see how you was writing code that was "good enough" to be shipped to production! That's the mindset I hope one day I will have. I shall ship as long as my code is readable enough and does the job.
    The perfectionist will never deploy something.

  • @TristanBailey
    @TristanBailey 2 ปีที่แล้ว

    You refactor so nicely when you talk through it. I sometimes imagine you talking when I do the same 😂

  • @mohammadashrafuddinferdous9347
    @mohammadashrafuddinferdous9347 2 ปีที่แล้ว +1

    Nice one! To my very personal opinion, i would rather use one codition and then return the result. I would omit else part and return if it reaches there! But I get your main point. We just need to recheck and refactor wneneer possible.

  • @udofiagodwin8194
    @udofiagodwin8194 2 ปีที่แล้ว +4

    Nice! Very nice! Personally, I would choose to keep the $isOnATeam variable so that I can change the value at a single point if ever there is a need to do so.

    • @TDarkCoder
      @TDarkCoder 2 ปีที่แล้ว +1

      Totally agree! Moreover it is always a better practice to choose resource over readability, however here even with assigning variable, readability did get worse.

    • @Laracastsofficial
      @Laracastsofficial  2 ปีที่แล้ว

      If you ever need to do that (with emphasis on ever), *then* you extract the variable.

  • @hollengrhen1
    @hollengrhen1 ปีที่แล้ว +1

    Tiny bits of refactoring **Proceeds to make an 18m long video** KEKW

  • @hassamulhaq7762
    @hassamulhaq7762 2 ปีที่แล้ว +1

    such kind of tutorials are really helpful.

  •  2 ปีที่แล้ว

    It seems to me it would be nice to use a technique inspired by early return - to set the "default" value outside of any conditionals. Then have one conditional block, that would set the more complicated values with query string, etc. It feels weird and prone to errors down the road to have the ternary duplicated.

  • @nonamechoosen
    @nonamechoosen 2 ปีที่แล้ว

    The message could also easily be inlined imo!

  • @DougLopes
    @DougLopes 2 ปีที่แล้ว +1

    Great tutorial of refactoring, not just for beginners, may i say.

    • @jeffreyway520
      @jeffreyway520 2 ปีที่แล้ว +1

      Thanks!

    • @adityakunhare
      @adityakunhare 2 ปีที่แล้ว

      Of course not for beginners, they should write code at first...

  • @proksalevente
    @proksalevente 2 ปีที่แล้ว

    At 7:45, what's the keyboard shortcut for selecting the whole thing?

  • @Bykv78
    @Bykv78 ปีที่แล้ว

    I liked everything you did, but I would only do the last part differently. I mean I prefer creating a variable rather than repeating the query.

  • @afsofatehabad1901
    @afsofatehabad1901 2 ปีที่แล้ว

    Very helpful..thanks a lot.

  • @jsjunior
    @jsjunior 2 ปีที่แล้ว

    Which PHPStorm theme are you using now? @Laracasts

  • @clashoftroopers4545
    @clashoftroopers4545 2 ปีที่แล้ว

    Love your lesson, 'n love listening to you.

  • @FilipePetter
    @FilipePetter 2 ปีที่แล้ว +1

    At 14:30 he referes to a method "Auth::user()->isOnATeam"
    English is not my first language, so I could miss something
    My question is, this "isOnATeam" is a built-in method or I have to create this method on the User's model ?

    • @Laracastsofficial
      @Laracastsofficial  2 ปีที่แล้ว +1

      You would manually add that method to your User model. And call it anything you want. $user->onTeam(), $user->isTeamMember(), etc.

  • @ycombinator765
    @ycombinator765 2 ปีที่แล้ว

    Thank You!!!!!

  • @khayamkhan2702
    @khayamkhan2702 2 ปีที่แล้ว

    amazing refactoring ...

  • @smtkumar007
    @smtkumar007 ปีที่แล้ว

    Mostly in my team after refactoring , it always ends with silly bugs

  • @wasidhossain3848
    @wasidhossain3848 2 ปีที่แล้ว

    wow 😲 it was really cool

  • @abrahamghaemi8895
    @abrahamghaemi8895 2 ปีที่แล้ว

    good job

  • @farazsalehi9034
    @farazsalehi9034 2 ปีที่แล้ว

    even with these little refactors .. i think its better to run unit tests .. because who would grantee that code still works ?

  • @KgfLikia
    @KgfLikia 2 ปีที่แล้ว

    Doing so to all files i visit... And asking devs to follow like stop declaring variables that are not variables or they are used only once.

  • @piaIy
    @piaIy 2 ปีที่แล้ว

    What do you think about destructuring assignment? You could rewrite it so that you have to check the condition only once:
    [$message, $url] = $isOnATeam ? ['message1', 'url1'] : ['message2', 'url2'];

    • @Laracastsofficial
      @Laracastsofficial  2 ปีที่แล้ว

      Yeah, if you want. I probably wouldn't go that route, but it's fine.