Tiny Refactors Make a Big Difference - Laracasts

Поделиться
HTML-код
  • Опубликовано: 1 окт 2024
  • In this Larabit, we’ll review some deconstructed, but typical real-life messy code that you’ll often find in the programming wild. Specifically, I want to talk about how, often, it’s the tiny refactors that can add up to make a massive difference in your applications. Watch thousands of videos, track your progress, and participate in a massive Laravel community at Laracasts.com.
    Laracasts: laracasts.com
    Laracasts Twitter: / laracasts
    Jeffrey Way Twitter: / jeffrey_way

Комментарии • 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..

  • @hollengrhen1
    @hollengrhen1 Год назад +1

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

  • @TimothySmithDev
    @TimothySmithDev 2 года назад +5

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

  • @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.

  • @FilipePetter
    @FilipePetter Год назад +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  Год назад +1

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

  • @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.

  • @jsjunior
    @jsjunior Год назад

    Which PHPStorm theme are you using now? @Laracasts

  • @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.

  • @mohammadashrafuddinferdous9347
    @mohammadashrafuddinferdous9347 Год назад +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.

  • @smtkumar007
    @smtkumar007 Год назад

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

  • @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.

  • @nonamechoosen
    @nonamechoosen Год назад

    The message could also easily be inlined imo!

  • @hassamulhaq7762
    @hassamulhaq7762 2 года назад +1

    such kind of tutorials are really helpful.

  • @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!

  •  Год назад

    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.

  • @VadimBesedin
    @VadimBesedin Год назад

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

  • @proksalevente
    @proksalevente Год назад

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

  • @TristanBailey
    @TristanBailey Год назад

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

  • @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.

  • @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...

  • @afsofatehabad1901
    @afsofatehabad1901 Год назад

    Very helpful..thanks a lot.

  • @clashoftroopers4545
    @clashoftroopers4545 2 года назад

    Love your lesson, 'n love listening to you.

  • @khayamkhan2702
    @khayamkhan2702 2 года назад

    amazing refactoring ...

  • @wasidhossain3848
    @wasidhossain3848 2 года назад

    wow 😲 it was really cool

  • @farazsalehi9034
    @farazsalehi9034 2 года назад

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

  • @ycombinator765
    @ycombinator765 2 года назад

    Thank You!!!!!

  • @abrahamghaemi8895
    @abrahamghaemi8895 2 года назад

    good job

  • @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.