Decorator Design Pattern in Laravel and PHP

Поделиться
HTML-код
  • Опубликовано: 11 июл 2024
  • Learn how to implement the decorator design pattern in Laravel and PHP.
    Let's discuss the benefits and the pros of using such a pattern.
    Socials:
    / nick_escobedo
    #decoratordesignpattern #php #laravel #designpatterns #designpatternsinphp
  • НаукаНаука

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

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

    This is so useful to have in mind when having different design patterns for certain use cases. Thanks a lot!

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

      Appreciate the kind words, thank you for your support!

  • @user-lp4no9tz1g
    @user-lp4no9tz1g 8 месяцев назад

    you can write this with pipeline. pipeline is very clean

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

    The WordCountDecorator doesn't actually output $text, aside from that, pretty cool video to explain Decorators.

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

      I don't follow. The decorator doesn't output anything because because the echo outputs the text to screen. The decorator only manipulates the string and returns it.

    • @yannlescouarnec9814
      @yannlescouarnec9814 Год назад +2

      @@esco_tech the last decorator only returns the word count and not the entire original string reformatted by the decorator. You missed that you should have the original string and three formatted strings in the test output and there is only three plus the word count.

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

      @@yannlescouarnec9814 Ahhh I see it now. Thank you! :)

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

    Is this really a suitable example of a decorator design pattern? I mean, you tried to apply the decorator design pattern by the way of pipeline design pattern.

  • @allan.koskei
    @allan.koskei Год назад

    Decorator seems very verbose, why wouldn't we have trim, mention and wordcount function enclosing a string. e.g echo trim_func(mention_func(wordCount_func($originalString))); These functions can also be tested separately

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

    share the github repo

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

      I don't have a repo at the moment, but that's a good idea. I'll potentially incorporate that in the future.