"Cruddy by Design" - Adam Wathan - Laracon US 2017

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

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

  • @TheKennyWorld
    @TheKennyWorld Год назад +12

    This talk is legendary, I come back once in a while to experience it again

    • @j.erlandsson
      @j.erlandsson 7 месяцев назад

      Literally went to the comments to say the exact same thing.

    • @undefined125
      @undefined125 Месяц назад

      Literally I am doing the same right now

  • @SimonDaviesOfCourse
    @SimonDaviesOfCourse 7 лет назад +67

    I have seen this being mentioned and that in several tuts, Jeffery Way talks about it on Laracasts, but I Must say.
    This is the best explanation and demo of this in action, with the comprehensive demo, it makes it easier to understand. Hat off to you Adam, another great explination :-)

  • @bashiordache
    @bashiordache 6 лет назад +30

    I dont even do Laravel, but this is so important

  • @Egadirov
    @Egadirov 5 лет назад +19

    16:35 "it doesn't matter, because we're not gonna run this code" - 😂

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

    That is the one technical knowledge sharing session about design patterns that worth priceless value.

  • @DAlbertsson
    @DAlbertsson 7 лет назад +20

    Amazing talk man! You totally inspired me to instantly get out of bed and go refactor! :)

  • @TristanBailey
    @TristanBailey 5 лет назад +2

    Adam, just come back and watched this again, sometimes when you are live coding I find you get way too detailed, but this was really educational and gave me things to work on. I have been trying to do resource controllers for a little while but someof your refactoring was good incite and way to revisit things too, thank you.

  • @esirei
    @esirei 3 года назад +2

    Yooo... that mutator trick in the pivot model is pure gold! 😳😃

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

    Simple, clean, and consistent. Excellent talk!

  • @tamrat_assefa
    @tamrat_assefa 6 лет назад +17

    Amazing presentation. api.php, here I come. Some housekeeping is in order.

  • @pisyek
    @pisyek 3 года назад +2

    Nice and simple approach! Will use "cruddy by design" in future projects.

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

    Among all other things, I learned that you can use spotlight search as a calculator directly. 😀. Great talk. Going to try this.

  • @whyisthereahandlenow
    @whyisthereahandlenow 4 года назад +7

    2:51 "Building Interfaces with Utility-First CSS"
    Quite the foreshadowing here

  • @JavierDiazGomez
    @JavierDiazGomez 7 лет назад +4

    Awesome talk, as always! Love your job and is really inspirational. Greetings from Chile, Adam!

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

    As someone on stackoverflow once told me...
    "Don't forget the single responsibility principle. Each function needs a single responsibility, the same can be extended to views, routes etc. For example, you have a controller responsible for submissions and a function responsible for editing said submissions."
    en.wikipedia.org/wiki/Single-responsibility_principle

  • @kwabenaberko5317
    @kwabenaberko5317 7 лет назад +5

    FInally!
    Was waiting patiently for this.
    Thanks Adam

  • @EduardoWeidmanBarijan
    @EduardoWeidmanBarijan 7 лет назад +5

    Thank you very much to make this talk available here.
    When I read about REST and about endpoints and all about that API driven design stuff I always end up banging my head thinking about how nested resources will work, what methods do I need, exactly like you pointed out.
    This way of thinking that everything is CRUD really makes sense to me and I will try to apply this in a project I have and yes it is a nightmare right now.
    The way you explain and show how it is done seems very easy to apply and I like the concept of changing the pivot table's name too. That I already do as it makes a lot more sense but I never thought about creating a separate Eloquent model, so thanks for that.

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

    A very interesting talk and it also opens up so many possibilities as well. Like for instance - currently the subscription controller only has two methods - store and destroy. What if you want to see a list of podcasts you subscribe to. Then you can create a list in the subscription controller as well (maybe). And - so - much - more ...

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

    The ever best inspiration to create more controllers as it costs nothing.

  • @RicardoVigatti
    @RicardoVigatti 5 лет назад +4

    This presentation is amazing!!

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

    before I watch this, I thought this is going to be repeated code and just a man who try the best for SOLID and some hell with the best practice but damn!
    this is gold, this is a killer design, especially the pivot naming xD

  • @NoodlesDream
    @NoodlesDream 3 года назад +3

    1. Nested Resource? 00:00 - 12:53
    2. Edited Independently? 12:54 - 17:10
    3. Touches Pivot Record? Eg.: "What do I have now that I didn’t have before?" 17:11 - 24:49
    4. Transitions State? 24:50 - 36:21

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

      thanks much. Your comment should be pinned on top so that people can easily navigate through the video.

  • @ahmedslink
    @ahmedslink 4 года назад

    Great talk.
    Tip1: Nested Controller? New Controller.
    Tip2: Edited independently: New Controller => (Updating profile image separately).
    Tip3: Touches pivot records? New controller and probably a new model => Subscription/Unsubscription
    Tip4: Transitions state? New Controller => Publish/UnPublish

  • @davidhernandeze
    @davidhernandeze 4 года назад +1

    Thank you Adam, you are always teaching me new lessons

  • @RoyShay
    @RoyShay 4 года назад +2

    Brilliant work. Thanks for this!

  • @johanneseriksson1929
    @johanneseriksson1929 4 года назад +1

    Such a great presentation!

  • @gojamoja6719
    @gojamoja6719 3 года назад +1

    Great work Adam

  • @Ribby00
    @Ribby00 6 лет назад +2

    I needed to see this! Awesome

  • @joejohn.
    @joejohn. 6 лет назад +23

    Man, I need to either switch to Sublime or step up my shortcut game.

    • @jackiemulsons
      @jackiemulsons 5 лет назад +3

      and as a Vim user, watching this makes me so glad I don't use Sublime. It's hard to watch somebody stumbling around so inefficiently...

    • @wouterkrooshof2527
      @wouterkrooshof2527 5 лет назад +2

      @@jackiemulsons What

    • @snelinternet4654
      @snelinternet4654 5 лет назад

      @@jackiemulsons ja precies. 😂

  • @StandingOva
    @StandingOva 7 лет назад +2

    Great Talk! Makes so much sense!

  • @LaurentPerrier
    @LaurentPerrier 7 лет назад +4

    Great talk, I like that you're showing a lot of common scenarios.
    1. How would you model a restore method for soft deletes as CRUD?
    2. Let's say you're building a proposal software, how would you model sending a proposal as CRUD? (considering you can send it more than once, unlike publishing)

    • @WalkaboutLifeVideos
      @WalkaboutLifeVideos 7 лет назад +5

      My guesses / what I would do after watching the talk:
      1. DeletedPostsController with an update = restore, delete = permaDelete
      2. Probably something like a ProposalDeliveryController with a create. The nice thing about this is that you could easily make a model associated and store records in the db of send times and destinations if you wanted to as well.

    • @EdmondKachale
      @EdmondKachale 7 лет назад +6

      1. Soft deleting a record means that you have _updated_ a certain flag to hide the record from a particular scope. So use _update_ for soft deletes and _delete_ for permanent deletes.
      2. If every time you send a proposal out, you _create a new record,_ it means that you will have to call a _create()_ on your controller. You can have _SendProposalController_ (or even _EmailProposalController_ which makes more sense if you are emailing them out).

  • @Virtualmix
    @Virtualmix 5 лет назад +7

    Funny how there's a manhole in the middle of the stage

  • @DanilDogadkin
    @DanilDogadkin 4 года назад +5

    What is the cruddy way to store / update / destroy multiple records at once?

  • @WalkaboutLifeVideos
    @WalkaboutLifeVideos 7 лет назад +3

    Is there a Laravel/PHP equivalent to the rails stats that DHH uses to grab the Controller count? I was trying to find something to run on my code.

    • @Badya122
      @Badya122 7 лет назад +4

      twitter.com/adamwathan/status/917082844001964039

  • @roshimon6670
    @roshimon6670 7 лет назад +1

    Awesome presentation. Learnt something valuable :)

  • @h0ph1p13
    @h0ph1p13 5 лет назад +1

    Excellent talk! Thank you!

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

    Hi Adam. Great Video. I have a question, If you want to have the option to download the cover image of a podcast. Should I add the action in the PodcastCoverImageController? What should it be the name of that action? action "show"? thanks so much.

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

    I actually downloaded and stored this because I'm afraid it's gonna be taken out of internet one day and I won't be able to go back to it and re watch

  • @Nscape-dl2js
    @Nscape-dl2js 5 лет назад +2

    what if for example i want a function that downloads a pdf ? that's not exactly a create function, i would just create a FilesController and create a download function to be honest.

  • @gustavovasquezveliz7046
    @gustavovasquezveliz7046 5 лет назад +2

    Amazing, i've learnt a lot

  • @饶泽海
    @饶泽海 4 года назад +1

    any suggestions on what the 'pseudo' resource and request urls could be for bulk actions?

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

      Perhaps it would be:
      Post: /pseudo-resource => PsuedoResourceBulkController
      Now you’ve set the scene for create update and delete pertaining to multiple records.

  • @lakhveersingh1065
    @lakhveersingh1065 4 года назад +1

    wow, that was great explaination

  • @ЮраПрудской
    @ЮраПрудской 5 лет назад +1

    What if I need to generate multiple tickets for a concert? Where does it go? Also, what if I need to validate a voucher validity?

  • @Shortly8908
    @Shortly8908 4 года назад +1

    Hi, Thank you for this video. I just want to ask how are you going to group these controllers? is it by modules?

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

    I always come back to this talk. I've built my apps using this technique and it works perfectly. Thank you for this.
    @adam if you ever read this, do you still use this technique?

    • @AdamWathan
      @AdamWathan  2 года назад +4

      That's awesome, glad to hear that! I definitely do, it's really nice to have a system for thinking about routes and controllers.

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

      Thank you! Keep up the great work.
      PS. Tailwind is awesome too!

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

    This is a light bulb moment for me 🙏

  • @bedramtamang1439
    @bedramtamang1439 3 года назад +1

    Re-watching again in 2021

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

    Great talk!

  • @truyenhot
    @truyenhot 3 года назад +1

    but what if we submit the cover with the form data when we create a podcast, hmm how do we separate it to update route, when podcast hasn't been created yet, still so vague and u didn't mention it

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

      you can do that by a separate Ajax call on your front end, uploading the image, returning its path, and then submitting it to
      the store route of your podcast
      .

  • @Paltibenlaish
    @Paltibenlaish 4 года назад

    if you have the logic for an action button like clear cache,
    where, if not the controller, do you put it?

  • @fernandezjasper
    @fernandezjasper 10 месяцев назад

    I learned a lot!

  • @1973superpippo
    @1973superpippo 6 лет назад +1

    thanks a lot, give me a different world

  • @rationalityfirst
    @rationalityfirst 7 лет назад +1

    Adam, do you think that the trick where you set an object as attribute should be part of Eloquent core? Or would it over complicate things? And nice presentation, as usually.

  • @matejl92
    @matejl92 5 лет назад

    Great video. Did a lot of refactoring to my apps using your tips. But I was wondering, where do Single Action Controllers (invokable controllers) come into place?

  • @ahmadaziz1800
    @ahmadaziz1800 5 лет назад +1

    LEGEND

  • @BestHKisDLM
    @BestHKisDLM 5 лет назад +1

    Great talk. Thanks.

  • @Dipenparmar12
    @Dipenparmar12 4 года назад +1

    Valuable .... content..

  • @AhmadAhmad-po4nl
    @AhmadAhmad-po4nl 4 месяца назад

    Looks great, but I'm wondering if this is still valid in 2024?

  • @paulselasiekitsi9195
    @paulselasiekitsi9195 5 лет назад +1

    This makes so much sense

  • @franzuaandrez5591
    @franzuaandrez5591 4 года назад +1

    Eres un genio! ;)

  • @arnaudlecat2913
    @arnaudlecat2913 6 лет назад

    Very interesting ! What if i have a "filter" method in a "PostController" ? Should i extract it to a "FilteredPostController" and rename it "index" in this logic ?

    • @andonovn17
      @andonovn17 5 лет назад

      Most of the times, you should be able to add the filters as part of the index action. If it’s mandatory to have a separate endpoint for some reason, then yeah a FilteredPostController with an index method is a good way to go imo

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

    Just Wow!!

  • @harykamaro5986
    @harykamaro5986 3 года назад

    Great explanation

  • @augustsbautra
    @augustsbautra 6 месяцев назад

    This! No more 10-20 action controllers!

  • @joelfunu1480
    @joelfunu1480 5 лет назад

    great talk. How would you design an endpoint for search a resource though?

    • @juanpadilla8760
      @juanpadilla8760 5 лет назад +1

      passing get parameters on the /index method should be fine, shouldn't it?

  • @elhadrami20
    @elhadrami20 4 года назад

    Very interesting

  • @bigollie006
    @bigollie006 5 лет назад +1

    This was worth $1000

    • @bigollie006
      @bigollie006 3 года назад

      @@BenGearig once I'm not delivering food, I will. I still deploy all my Laravel apps on Forge and purchased the TailwindUi package to support the man even on my limited budget. Does that count?

  • @ManuelBTC21
    @ManuelBTC21 4 года назад

    Holy line-height batman

  • @MrFranciscoooooo
    @MrFranciscoooooo 3 года назад

    6*
    An controller with 1 action only shouldn't have just __invoke()? @Adam

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

      why would it? by using invoke, you let nobody know what the intention of said method is. Destroy? store?

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

      @@Jossnaz now I don't remember my use case for this question :/

  • @Aalii6
    @Aalii6 11 месяцев назад

    👍👍

  • @yinzhang7814
    @yinzhang7814 4 года назад

    It should be use PATCH instead of PUT method when update cover image.

    • @rizaldywirawan
      @rizaldywirawan 4 года назад

      what's the difference between PUT and PATCH?

    • @饶泽海
      @饶泽海 4 года назад +2

      fine line and a little subjective - but - patch is partial update, put is replacing the whole object - so you could argue that since his 'resource' is a PodcastCoverImage, he is replacing the whole object and therefore a PUT should be used

    • @AdisDurakovic
      @AdisDurakovic 3 года назад

      @@rizaldywirawan PUT when updating the whole object, PATCH when updating only parts of it, like "upddated_at" or "status", etc..

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

    Thanks for awesome talk.
    What if I want to call an api to check if current name of a user has been taken in the DB.
    What would be the best naming for that api end point?
    Is '/user/{name}/has-duplicate-name' ok?

  • @Chavez3d
    @Chavez3d 4 года назад

    in my mind this begs the question why not Route::get('/resource/create', CreateResource::class) and let the invoke take care of the create action and just have actions as classes... with one public method and whatever you need for private helpers... Why even have a "resource" controller? I like this talk and the ideas in it... it certainly cleans things up but why not just take it to the extreme and make everything super-specialized...

  • @JulioCesar-hh9wq
    @JulioCesar-hh9wq 3 года назад

    This guy gives me some Joe Rogan vibes, great presentation

  • @devaes
    @devaes 3 года назад

    NWA

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

    Nice talk, even so I would disagree with the subscriptions and published podcasts resources. For me it would be /podcasts/{id}/subscription and /podcasts/{id}/publication and I don't have to pass the podcast id via the request body. I moves related stuff a lot more together.