Understanding and implementing Value Objects

Поделиться
HTML-код
  • Опубликовано: 3 авг 2024
  • 👨‍💻 Learn Test-Driven Development with Laravel!
    tddwithlaravel.com
    Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com
    👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis:
    subscribe.mateusguimaraes.com
    🎉 Party up:
    / mateusjatenee
    / mateusjatenee
    / mateusguimaraes
    Thanks for watching!
  • НаукаНаука

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

  • @ryanharmon1408
    @ryanharmon1408 9 месяцев назад

    This should be one of the top 100 viewed videos regarding Laravel on RUclips.

    •  9 месяцев назад

      Thank you so much Ryan!

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

    vc é brabo demais!!

  • @darkbelg
    @darkbelg Год назад +3

    Are value objects an evolution of DTOs?

    • @williamxsp
      @williamxsp Год назад +4

      Kinda. DTO just cares about the shape of the data. In this case, temperature is an integer so thats it. It doesnt validate and it doesnt care about the business. It just force you to have the data in the format that you need (array, string, integer and so on). Once you need to have valid data in the domain perspective, like temperature cant be below -20 you have a value object.
      Not an evolution but just different use cases.

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

    Is the value object also responsible to convert the temperature from one unit to another?
    for example:
    $temperature = new temperature(100, 'celsius');
    $temperature->getFahrenheit(); // 212
    or
    $temperature = Temperature::fromCelsius(100);

    • @chlouis-girardot
      @chlouis-girardot Год назад

      for me, yes !

    •  Год назад +1

      It’s common to have formatting inside a VO. Just try not to go overboard with it :-)

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

    What font are you used for your phpstorm?

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

      Operator Mono

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

    Instructions unclear.
    $request->validate(['temp' => ['min:-20', 'max:60']]);
    Problem solved.

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

      That works from the http request perspective but sometimes you will find yourself reading data from a CSV uploaded by the user or from a command line. Value objects can be useful in such situations.

    •  Год назад

      Big brain energy