Value Objects Practical Example - What is a Value Object? - Full PHP 8 Tutorial

  Рет қаралды 18,783

Program With Gio

Program With Gio

Күн бұрын

Пікірлер: 79
@megyptmEgy
@megyptmEgy Күн бұрын
Thank you so much for the amazing PHP courses you share online! Your tutorials have been a game-changer for me, and I can't express how much I’ve learned from your clear and practical explanations. Your passion for teaching and your ability to simplify complex concepts have inspired me to keep growing as a developer. I'm so grateful for all the effort and dedication you put into helping people like me learn and improve. Keep up the fantastic work-you’re making a real difference in the lives of so many aspiring developers!
@mwaas
@mwaas Жыл бұрын
After every lesson I feel lucky to be watching this wonderful course
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Happy to hear that
@andersoncdz1
@andersoncdz1 2 жыл бұрын
Bro, you are amazing, your php 8 course is incredible, thank you very much for this gem.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Glad you like it, thank you 💙💙
@benderbg
@benderbg 3 ай бұрын
19:18 This refactoring felt like the speed of light 🚀💪
@ProgramWithGio
@ProgramWithGio 3 ай бұрын
Glad to hear 💙
@aryank8695
@aryank8695 2 жыл бұрын
I am very thankful you make such quality videos. Please keep making more videos on concepts like these, these are very helpful. I really feel like learning a lot in short time watching your videos.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Glad to hear that, thank you 🙏
2 жыл бұрын
Great video, Gio. Thank you!
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 💙💙
@SerhiiDorn
@SerhiiDorn 2 жыл бұрын
You make great content. Thank You much. Your code style is highly elegant. I'm looking forward to form request, auth, authorization, middleware, and several most common patterns using in laravel
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you and thanks for suggestions 💙
@stephen.cabreros
@stephen.cabreros Жыл бұрын
awesome and fantastic. I might gonna use this reference someday. Immutable and side effect free values makes ease by making it less prone to bugs, don't know yet when to use the equalTo method for checking equality. But I might figure it out someday, thanks
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you
@memack101
@memack101 2 жыл бұрын
Thank you Gio.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
No problem 💙💙
@OlayDede
@OlayDede 2 жыл бұрын
Thank you for the great content, Gio!
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 💙
@vegekou100
@vegekou100 Жыл бұрын
Pure Gold 🏆
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you
@AMoktar
@AMoktar Жыл бұрын
Awesome video, thanks
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Glad you liked it
@chlouis-girardot
@chlouis-girardot 2 жыл бұрын
Thanks Sir 🙏, awesome content, it's cristal clear 👌
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You're welcome
@manh9105
@manh9105 2 жыл бұрын
Hi! there is an additional 'i' in entity ! Have enjoyed this course to the fullest , would use it as reference for years to come!!
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Hey, thank you so much 🙌. I didn't notice the typo, could you share the timestamp on where it is?
@manh9105
@manh9105 2 жыл бұрын
@@ProgramWithGio 8.40 & 20.46 respectively! Thank you for this wonderful series
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
@@manh9105 hahaha 🤣🤣, omg how did I not notice that. That looks so funny now 😂. Thank you 🙌 good eyes 👀
@manh9105
@manh9105 2 жыл бұрын
@@ProgramWithGio Most Welcome 😄
@MuratUysal
@MuratUysal 2 жыл бұрын
You are great teacher.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you 🙌
@pusikurac986
@pusikurac986 2 жыл бұрын
do you plan on doing some videos on most common design patterns in php?
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Maybe in the future.
@elmarzougui
@elmarzougui 2 жыл бұрын
Great Content
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you
@mohdsyafiqjohar6883
@mohdsyafiqjohar6883 7 ай бұрын
Hi,, Thank you for a wonderful video & deep explanation about it.. It's really easy to understand.. May I know, what is the PHPStorm plugin that you using to make this sign '->', '===', etc pretty? I seen it in your another video..
@ProgramWithGio
@ProgramWithGio 7 ай бұрын
It's not a plugin, I have font ligatures feature enabled in my IDE
@MayankJaniOfficial
@MayankJaniOfficial 6 ай бұрын
Hi Gio, big thanks for these PHP tutorials. I have years of experience, but after these videos, I still learnt a lot and now much more confident. Btw do you have any recommendations for similar types of videos for Javascript? I have watched Laracasts but looking for something different.
@ProgramWithGio
@ProgramWithGio 5 ай бұрын
Thank you. I'm not involved much in the JS content to be honest so I'm not sure. I usually check traversymedia or laracasts.
@SlainR2
@SlainR2 2 жыл бұрын
very good, Gio!
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thank you
@free2idol1
@free2idol1 2 жыл бұрын
Thanks for awesome video again. But at 21:15 does DTO has no id? i.e what if we have a DTO that represent a User model in laravel? User instance must have id then how come its DTO does not?
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
No DTO has no id. That is Entity, you would have User entity. DTO is just to pass data around so like take form request parameters create DTO and pass that DTO to a service class to create the User entity
@free2idol1
@free2idol1 2 жыл бұрын
@@ProgramWithGio thanks for your reply... But that seems to just 1 use case of DTO, there is another scenario where DTO can be used as api resource. There is a package called "spatie-laravel-data" which allows id property in DTO (check section "as-a-resource/from-data-to-resource" at its doc for detail).
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
@@free2idol1 sure, I just gave you one example since you asked. There are more uses for DTO for sure and API is one of them, I showed API example as well in the video. I have not used that package, DTOs typically dont have an ID and business logic. If someone implemented it with ID it's up to them, maybe has a special use case.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
@@free2idol1 I checked the package and they call those Data Objects and use it for multiple purposes. Within the "as DTO" section you will see there is no ID. So that package isn't just DTO, it's more like a multipurpose DTO.
@free2idol1
@free2idol1 2 жыл бұрын
@@ProgramWithGio Okay... it seems they've mixed 2 concepts (DTO and Entities) in that single package. Do you think so? Also, if I put `public ?$id` in the DTO, then what would be the consequence later on? And how to apply Entitiy concept in Laravel? or a Eloquent Model already represents an Entity?
@IvanVlk
@IvanVlk 2 жыл бұрын
I'm really excited about how introducing ORM crippled Entitites into some data-db objects, so you need to introduce things like Value Objects to heal your improper object design. "Entities are normally identified with ID" - yes? Since when? Entity is normal object with properties and methods. Like any other object. Just using ORM made them so. Even senior developers are crippling the OOP by using ORM and then using external "services" to implement methods, which should be integral to object (entity). And then adding artificial IDs to every entity, so no one really understand the code nor DB structure, because is full of IDs you don't really need for anything (because you have composite keys, right?). To conclude this: you don't need any VO here. Simply use your entities and set their properties by other entities, like dimension etc. Sure, you can make them immutable, by default, or by method. Then your object of PackageDimnension class is valid for whole module, even for another entity, like Pallet. Then pick your pre-set PriceCounter, feed it with Package object and it will set the price. Then just pass the object into some kind of mapper to store value, that's it.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You make some good points & I partially agree, but Value Objects are a big part of DDD design and part of the PHP ecosystem, and so are entities. This is why I decided to cover it because new devs will eventually work with some sort of ORM or come across these terms and is important for them to know what they are and what is the difference. We covered Entities earlier in this series (within ORM & Doctrine/Symfony context) so explaining the difference in that context was important.
@hansschuijff
@hansschuijff 2 жыл бұрын
Valuable lesson again, Gio,. Thank you. In the code you kept the new enum, VO's and Service class together in a directory. Is that what you would normally do? I can see they are related and perhaps the only relevance for them is in that service, but you also created an enum directory in the app, so I wondered if there are rules in that you follow.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Good observation. I usually put them in their own directories like Data Objects and place value objects & DTOs there. I didn't pay attention to the folder structure in this lesson cause I probably got carried away talking 🙈. In the project section you will see that we will have DataObjects directory. Also this comes down to preference, some like to group related classes in their own domain/directory. Like Shipping could be a directory and everything related to shipping within there and so on. I wouldn't definitely put everything under Services though, so good catch 👍
@Zubbee
@Zubbee 2 жыл бұрын
Hi Gio, I enjoyed this video. Learning further to simplify an application and make it easier to manage. But pls, why did we need to create the equalto() function? I didn't quite get that. Why do we need to compare the the other value object with the current value object? I understood the function, its the "why" I didn't get. Thanks a lot Gio.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You may need to compare two value objects. Having equal to method allows you to set how the objects can be compared. You can still compare them using == which will compare property values but as I mentioned it will do loose comparison. With custom equal to method you can do strict
@Zubbee
@Zubbee 2 жыл бұрын
@@ProgramWithGio Ok Gio, I understand it better now. Thanks a lot.
@josechirino5168
@josechirino5168 2 жыл бұрын
Really helpful, thank you
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Glad it was helpful, thank you 🙌
@pasizdobrekuce
@pasizdobrekuce 2 жыл бұрын
Wow man! This is so so useful. Thank you so much! Please if you have time (and will), make a short series on DDD.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Glad you liked it, thank you. Unfortunately I don't follow DDD and don't know much about it. Maybe in future I can make a series about it & learn it myself along the way 👍. Thanks for the suggestion
@pasizdobrekuce
@pasizdobrekuce 2 жыл бұрын
@@ProgramWithGio We started to implement it in our legacy and it opened our eyes (almost literally). Everything makes much more sense.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
@@pasizdobrekuce that's awesome
@free2idol1
@free2idol1 2 жыл бұрын
@@ProgramWithGio may I know why you don't prefer DDD and what architecture/ design method you often use in your development process? I am researching DDD and it seems articles about it on the internet is mainly theory-based.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
@@free2idol1 it's not that I don't prefer, I typically do monoliths with a bit of microservices
@codingzen869
@codingzen869 2 жыл бұрын
PHP design patterns stuff would be a nice addition if it's not already planned on the series. Very few resources on this on YT.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thanks for the suggestion, no plans yet but it's in my list
@devcast6414
@devcast6414 2 жыл бұрын
Thanks
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You're welcome
@Abdulrahman-my3tu
@Abdulrahman-my3tu 2 жыл бұрын
I suggest that you make Laravel course. Thank you
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Thanks for the suggestion 💙
@truthteachers
@truthteachers Жыл бұрын
In my view, DTO should called as Data Transformation Object as i see it was only doing transformation and not transfer. This is very similar to what we do in Data Warehousing using ETLs. I may be wrong.
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Data transformers can also be another type of class. DTO is used for transferring data though can be used to transform as well, so in a way you could say DTO is also a transformer since it transforms arrays or unstructured data into structured objects. DTOs are also immutable and read-only.
@truthteachers
@truthteachers Жыл бұрын
@@ProgramWithGio Tq you for the clarification.
@rxxt-sh1vj
@rxxt-sh1vj 2 жыл бұрын
Please also make a video on building middleware from scratch and its implementation without using any framework
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Not planned currently but will add this to the list, thanks for the suggestion
Intro to Templating Engines - Blade & Twig - Full PHP 8 Tutorial
13:29
Program With Gio
Рет қаралды 21 М.
PHP Enums With Practical Examples - Full PHP 8 Tutorial
28:13
Program With Gio
Рет қаралды 27 М.
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
Почему Катар богатый? #shorts
0:45
Послезавтра
Рет қаралды 2 МЛН
5 Rules For DTOs
17:56
Ardalis
Рет қаралды 46 М.
Data Transfer Objects - What Are DTOs - Full PHP 8 Tutorial
13:03
Program With Gio
Рет қаралды 43 М.
Understanding and implementing Value Objects
15:10
Mateus Guimarães
Рет қаралды 1,4 М.
Value Objects
8:12
Coding Concepts
Рет қаралды 18 М.