I am really enjoying all of your lessons, you explain things in depth while keeping it understandable for most people. Even advanced developers can learn something new here. I have been writing PHP applications until 2 years ago when I stopped, I follow your lessons to get back into the game, and it's working! Thanks for all the effort you put into making them.
It's not my first time learning OOP concepts, but the first time, when someone clearly say that using simplest getter and setter with private property isn't encapsulation at all! It doesn't change a thing! The property is still absolutely accessible, but with more text to type in and read! I always understand this, but thought that maybe... I don't understand something?.. Gio the best!
Your Tutorial is the best! Easy to learn interactively (don't learn PHP programming without a editor and browser ready). Way better than any page I found. I started making my own MVC in PHP with little to no knowledge about OOP. As a sysadmin, Bash and Python are quite familiar in a functional way. Getting my head around OOP was hard at first, but now things are coming together as I learn more essential stuff.
I already knew about public and private properties and methods but I didn't know about those two ways of accessing private properties. Why do those things exist? Doesn't it defeat the purpose of having private stuff in the first place? By the way, I LOVE these videos. Thank you so much for taking the time to make this guide. I feels like something I should have to pay for.
Thank you, appreciate it. Language supports a lot of things, doesn't mean everything should be used by everyone. Some of those things can be useful for libraries, packages, and some edge case scenarios.
Thanks a lot for such a great tutorial. Watching your videos seems like watching a excellent quality Web Series which keeps the viewer engaged and curious of what the next episode is going to bring up. Guess what!!!!!!. The next episode exceeds the expectations and the bar for viewers expectations rises to next level. It is quite addicting to watch Ur content. It feels like I finish all the episodes at one go. Also I am expecting what the Movie Director has to come up next. Seeing to the in-depth knowledge over the subject and great presentation skills i would suggest if you could bring up a series on "DESIGN PATTERNS - THE GIO's way" would be an ideal candidate for future releases!!!!
5:45 - that's an idea similar to the concept of immutability of an object, where you're not allowed to modify an already existing object. The only way of making changes is by creating a new instance with new/updated properties.
I am working to get my php code compitable with PHP8.1, and static analyze tools found that I had classes, where some arguments in constructor with default values were before values without default fallback. In tottal it accepts 5-10 values in constructor) Now I found that this class is called in about 10 files. I had to rearrange those arguments, change values in those files. Properties were all public. No setters. Does this means that somebody who wrote this class was not following best encapsulation practices, right? But basically, it is simple DTO, with two methods to check it state, and another method to get another object based information from this class. What would be the better approach? Just use chain setters? Or couple some information pieces together in another smaller DTOs, so it the main DTO would have only 3 arguments in constructor? But I see that it is usually used to fill array value, and it would increase indentation. But now, PHPstorm is even struggling showing all the argument names :D
Having public properties means that it can be written to outside of the class. So inevitably it has conflict with encapsulation. If you don't want those properties to be editable you can use readonly keyword for the properties and keep them public. DTOs should be immutable anyways so readonly properties should work
Getters and Setters are not that bad... They are not only made because of encapsulation, but you have better control about what can be written to that private property. In your case it shouldnt be a big problem, because your property is properly defined as a float, but with older code wihtout types this could be a problem. You could define $transaction->amount = 'Hello There' instead of a float number. With a proper Setter you could easily throw an exception if the value is not an int or float.
Definitely. I mentioned that in the video as well. There are use cases for Getters and Setters outside of simple encapsulation implementation, they are not just for encapsulation. As mentioned in the video sometimes they can break encapsulation instead of fixing it. You brought up a good example with the types, that is also correct, if one doesn't use strict types then definitely setter is good to enforce the type and have proper "validation".
I read in a book's intro about design patterns where Abstraction was mentioned in OOP's context and the explanation was that abstraction means that objects only model attributes and behaviors of real objects in a specific context. It kind of does not seem to fit with the way you described abstraction or am I missing/misinterpreting something? The example in the book was about a plane, how in the context of a flight simulator, we would care about certain physical aspects that would matter in simulating a flight realistically, but in a booking application we would only care about seats, their availability. I am assuming that abstraction is a broader topic and that both you and the author in the book just provided a small fragment of the same topic? In the book it was just a couple paragraphs before moving on to the next topic. Book for reference is "Dive Into Design Patterns" by Alexander Shvets
Yea I think we both are talking about the same thing, though the definition in book may be a bit more fancier. Abstraction is simply where the implementation details are sort of hidden away (abstracted away) from you, so in your example in the context of booking, the user does not care how the booking system is implemented, all the user cares about is to click a button & confirm the flight. To translate that into code, you might have a class called Booking with a method called book. As the user/developer who wants to consume that API & create a booking, all you need to do is instantiate a new Booking class & call the book method, you don't care what happens inside the book method or how its implemented, no other setup is needed by you, all you care about is that booking is created after you call the book method. That's what abstraction is in simpler terms.
Exposing the setter method is not like making the property public, because with setter u have control to check and manipulate the value. u can have criteria to check the value if it meets the criteria or not. In future if u change the rules for the value, u can just change it in one place in setter. Setter method makes it more secure and under control.
Seems like php changes occurred. At 4:25, when i tried to pass setAmount function it results in: Fatal error: Uncaught TypeError: App\PaymentGateway\Paddle\Transaction::setAmount(): Return value must be of type float, none returned. Expected type 'float'. Found 'void'.intelephense(1006). public function setAmount(float $amount): float # setter function for changing the private (encapsulated) property { return $this->amount = $amount; } The way it start working for me.
Don't think anything changed related to that. You just need to return the proper type. If you do $this->amount = $amount then you need to return $this->amount.
Is ReflectionProperty php class/php api built in or does it require installation via a composer sort of?. Great tip/trick at the end. Thanks for being awesome
Thank you so much for this course, the content is great, but those popping-up subscribe banners even for users who already subscribed to your channel are a bit annoying. Please, could you do something about it? Thanks again.
They pop up only a couple of times, I don't think is a big deal 🙂. I also put them in places where not much is going on so it doesn't block anything important.
Hi Bro, your courses are comprehensive unfortunately many of the newbies to PHP in our developer group in the region gave up on your courses. The reason they say is the "rambling on" effect of your presentation. I have mentioned this before. My recommendation is to redo these videos and provide detail explanation. Of course, your effort needs to be rewarded as well. Suggestion is to launch the course in Udemy. Also suggest you timestamp the video as well especially when you cover many topics/concepts in one video. Like this one, i dont know where abstraction starts when i come back later for reference. I hope you do not take these as negative comment but instead use it positively. Tq bro.
Hello. Thank you for the feedback. I agree on couple of parts like having timestamps & on previous videos I speak too fast due to editing errors & the way I speak. That being said though, whoever thinks I am "rambling" can go and watch something else, I've got no problems with that. I am not going to redo these videos into an Udemy course. Also I'm not sure what you mean by "provide detail explanation", all of my videos are very detail oriented, it doesn't get any more detailed than that, that's why this series has almost 100 videos in it & is not a "Learn PHP in 3 hours" crash course because it's very detail oriented. You can even see that based on the feedback from the comments on every single video on how detailed it is. I'll try adding timestamps on future videos. P.S. If they don't understand something or have any specific questions they can always reach out & post comments themselves, I'll be happy to assist & clarify things that may be confusing to them.
@@ProgramWithGio Bro, no one said it is garbage. Perhaps the course is not meant for absolute newbies to PHP. Anyway that is their feedback. Take or drop is your choice. Please dont shoot the pigeon. I am conveying their views and also to avoid 100s of dislikes for all your good effort. Anyway, my apology for upsetting you emotionally.
@@truthteachers I'm not upset and I appreciate the feedback. As I said they can ask me questions directly if something was confusing and I'd be happy to help. I've helped many. I'm not afraid of dislikes either. I just care about this stuff because if something is confusing I want to know specifically what and improve on it and also help the person who is confused. Someone just saying "rambling" is not helpful, if they were to say specifically what was confusing or what they didn't understand I would be happy to help. Either way, thank you 💙
Nothing against you btw :). I understand you are just conveying their views and I appreciate that. There are many complete beginners who took this course and had no issues, so I think it can work for complete beginners. Some things certainly can be confusing and that's why I offer my help to those who need it.
That is true, but it also depends on what kind of car you give to the client. If you give it a well-designed & functional car, the client will be safer. If you give them a car that malfunctions then it's not so safe. So, in the end, it's correct that the client doesn't care how a car operates but they do care that their car is fully functional & operational
Best PHP and complete course. Better than many paid bootcamps and best quality
Dammann I'm glad I found this channel
I'm glad as well 🙌
This is one of the best course I've ever seen... Not just how to write php code, but it also explain how to write idiomatic code.
Thank you
The best USEFUL ADVANCED php series on the youtube 👑❤ ... Thanks for that trick
You're welcome and thank you 🙌
I am really enjoying all of your lessons, you explain things in depth while keeping it understandable for most people. Even advanced developers can learn something new here. I have been writing PHP applications until 2 years ago when I stopped, I follow your lessons to get back into the game, and it's working! Thanks for all the effort you put into making them.
Thank you so much, that means alot 💙
that last bonus trick at the end was amazing, my mind is blown... great job, another amazing video!!
Thank you 🙌
It's not my first time learning OOP concepts, but the first time, when someone clearly say that using simplest getter and setter with private property isn't encapsulation at all! It doesn't change a thing! The property is still absolutely accessible, but with more text to type in and read! I always understand this, but thought that maybe... I don't understand something?..
Gio the best!
Heh, yup. It's usually misunderstood. Thank you 🙏
Only This course gave me confidence that I can reach the advanced php level. Brilliant ! Thanks !
Great to hear, thank you
Just wanted to let you know, that your tutorials are awesome
I appreciate it, thank you 🙌
Your Tutorial is the best! Easy to learn interactively (don't learn PHP programming without a editor and browser ready). Way better than any page I found.
I started making my own MVC in PHP with little to no knowledge about OOP. As a sysadmin, Bash and Python are quite familiar in a functional way. Getting my head around OOP was hard at first, but now things are coming together as I learn more essential stuff.
That's awesome, thank you 💙💙
I already knew about public and private properties and methods but I didn't know about those two ways of accessing private properties. Why do those things exist? Doesn't it defeat the purpose of having private stuff in the first place?
By the way, I LOVE these videos. Thank you so much for taking the time to make this guide. I feels like something I should have to pay for.
Thank you, appreciate it. Language supports a lot of things, doesn't mean everything should be used by everyone. Some of those things can be useful for libraries, packages, and some edge case scenarios.
best php tutorial on youtube
Thank you 🙌
Again, great lecture
Thank you 🙌
4:00 this was what I have always wondered about. Thanks for answering.
That's awesome
I used to confuse Abstraction and Encapsulation. Thanks for the explanation!
You're welcome
great explanation...I'm loving this series...I am making my own document to sum up my PHP knowledge, and this series is HELPING ALOT!! Thanks!!
That's great to hear, thank you 🙏
loving your vids, GOAT ty
Thank you 💙
Great lesson, I followed. Also heard when you said we may have to listen again, I will do well to do that tomorrow. Thanks Gio.
Great to hear, thank you
Thanks a lot for such a great tutorial. Watching your videos seems like watching a excellent quality Web Series which keeps the viewer engaged and curious of what the next episode is going to bring up. Guess what!!!!!!. The next episode exceeds the expectations and the bar for viewers expectations rises to next level. It is quite addicting to watch Ur content. It feels like I finish all the episodes at one go. Also I am expecting what the Movie Director has to come up next. Seeing to the in-depth knowledge over the subject and great presentation skills i would suggest if you could bring up a series on "DESIGN PATTERNS - THE GIO's way" would be an ideal candidate for future releases!!!!
Thank you for this feedback, happy to hear 💙💙
Extemly superb teaching
Thank you 💙
I want to give a double thumbs up!
💙💙
Thank you so much! Your lessons are pure gold!
Glad you like them, thank you
Thank you for all this awesome instruction!
You're welcome 💙
Your videos are really beautiful and easy to learn.💗💗💞💞
Thank you so much, glad you like them ❤️❤️
@@ProgramWithGio Make some videos in Design pattern.
Thank you
You're welcome
What compiler do you use? like that, that has live server web extension that easily refresh code changes
I don't use any compiler or extensions, its just my IDE phpstorm but I refresh the page manually, I just sometimes cut things out during editing
These videos are really enjoyable, good job buddy
Glad you like them, thank you 🙌
fantastic explanation, thank you a lot!
You are welcome 🙌
Excellent ! Thanks!
Glad you liked it!
5:45 - that's an idea similar to the concept of immutability of an object, where you're not allowed to modify an already existing object. The only way of making changes is by creating a new instance with new/updated properties.
Yup that is right
Thank you.
You're welcome 💙
I am working to get my php code compitable with PHP8.1, and static analyze tools found that I had classes, where some arguments in constructor with default values were before values without default fallback. In tottal it accepts 5-10 values in constructor) Now I found that this class is called in about 10 files. I had to rearrange those arguments, change values in those files. Properties were all public. No setters.
Does this means that somebody who wrote this class was not following best encapsulation practices, right?
But basically, it is simple DTO, with two methods to check it state, and another method to get another object based information from this class.
What would be the better approach? Just use chain setters? Or couple some information pieces together in another smaller DTOs, so it the main DTO would have only 3 arguments in constructor? But I see that it is usually used to fill array value, and it would increase indentation. But now, PHPstorm is even struggling showing all the argument names :D
Having public properties means that it can be written to outside of the class. So inevitably it has conflict with encapsulation. If you don't want those properties to be editable you can use readonly keyword for the properties and keep them public. DTOs should be immutable anyways so readonly properties should work
Getters and Setters are not that bad... They are not only made because of encapsulation, but you have better control about what can be written to that private property.
In your case it shouldnt be a big problem, because your property is properly defined as a float, but with older code wihtout types this could be a problem.
You could define $transaction->amount = 'Hello There' instead of a float number. With a proper Setter you could easily throw an exception if the value is not an int or float.
Definitely. I mentioned that in the video as well. There are use cases for Getters and Setters outside of simple encapsulation implementation, they are not just for encapsulation. As mentioned in the video sometimes they can break encapsulation instead of fixing it.
You brought up a good example with the types, that is also correct, if one doesn't use strict types then definitely setter is good to enforce the type and have proper "validation".
@@ProgramWithGio Yes, I was also thinking about legacy code, where not every type is available.
Nice tutorial
Thank you 💙
thank you!
You're welcome
I read in a book's intro about design patterns where Abstraction was mentioned in OOP's context and the explanation was that abstraction means that objects only model attributes and behaviors of real objects in a specific context. It kind of does not seem to fit with the way you described abstraction or am I missing/misinterpreting something?
The example in the book was about a plane, how in the context of a flight simulator, we would care about certain physical aspects that would matter in simulating a flight realistically, but in a booking application we would only care about seats, their availability.
I am assuming that abstraction is a broader topic and that both you and the author in the book just provided a small fragment of the same topic? In the book it was just a couple paragraphs before moving on to the next topic.
Book for reference is "Dive Into Design Patterns" by Alexander Shvets
Yea I think we both are talking about the same thing, though the definition in book may be a bit more fancier. Abstraction is simply where the implementation details are sort of hidden away (abstracted away) from you, so in your example in the context of booking, the user does not care how the booking system is implemented, all the user cares about is to click a button & confirm the flight. To translate that into code, you might have a class called Booking with a method called book. As the user/developer who wants to consume that API & create a booking, all you need to do is instantiate a new Booking class & call the book method, you don't care what happens inside the book method or how its implemented, no other setup is needed by you, all you care about is that booking is created after you call the book method. That's what abstraction is in simpler terms.
@@ProgramWithGio Appreciate the detailed response, thank you for clarifying that
Thank you!!!
You're welcome!
Awesome! I love, mate!
💙💙
Exposing the setter method is not like making the property public, because with setter u have control to check and manipulate the value. u can have criteria to check the value if it meets the criteria or not. In future if u change the rules for the value, u can just change it in one place in setter. Setter method makes it more secure and under control.
Sure, but it still gives ability to change the state of your class. It has it's use case though, don't get me wrong.
Seems like php changes occurred. At 4:25, when i tried to pass setAmount function it results in: Fatal error: Uncaught TypeError: App\PaymentGateway\Paddle\Transaction::setAmount(): Return value must be of type float, none returned.
Expected type 'float'. Found 'void'.intelephense(1006).
public function setAmount(float $amount): float
# setter function for changing the private (encapsulated) property
{
return $this->amount = $amount;
}
The way it start working for me.
Don't think anything changed related to that. You just need to return the proper type. If you do $this->amount = $amount then you need to return $this->amount.
I had the same type error, and return $amount; helped; In Gio video there is no Return;
Is ReflectionProperty php class/php api built in or does it require installation via a composer sort of?. Great tip/trick at the end. Thanks for being awesome
It's part of PHP. We'll cover Reflection in more detail soon in third section of the series.
@@ProgramWithGio thanks Gio. When is part 3 by the way?
Should be able to start next week I think. Been super busy recently
Thank you so much for this course, the content is great, but those popping-up subscribe banners even for users who already subscribed to your channel are a bit annoying. Please, could you do something about it? Thanks again.
They pop up only a couple of times, I don't think is a big deal 🙂. I also put them in places where not much is going on so it doesn't block anything important.
Hi Bro, your courses are comprehensive unfortunately many of the newbies to PHP in our developer group in the region gave up on your courses. The reason they say is the "rambling on" effect of your presentation. I have mentioned this before. My recommendation is to redo these videos and provide detail explanation. Of course, your effort needs to be rewarded as well. Suggestion is to launch the course in Udemy. Also suggest you timestamp the video as well especially when you cover many topics/concepts in one video. Like this one, i dont know where abstraction starts when i come back later for reference. I hope you do not take these as negative comment but instead use it positively. Tq bro.
Hello. Thank you for the feedback. I agree on couple of parts like having timestamps & on previous videos I speak too fast due to editing errors & the way I speak. That being said though, whoever thinks I am "rambling" can go and watch something else, I've got no problems with that. I am not going to redo these videos into an Udemy course.
Also I'm not sure what you mean by "provide detail explanation", all of my videos are very detail oriented, it doesn't get any more detailed than that, that's why this series has almost 100 videos in it & is not a "Learn PHP in 3 hours" crash course because it's very detail oriented. You can even see that based on the feedback from the comments on every single video on how detailed it is.
I'll try adding timestamps on future videos.
P.S. If they don't understand something or have any specific questions they can always reach out & post comments themselves, I'll be happy to assist & clarify things that may be confusing to them.
@@ProgramWithGio Bro, no one said it is garbage. Perhaps the course is not meant for absolute newbies to PHP. Anyway that is their feedback. Take or drop is your choice. Please dont shoot the pigeon. I am conveying their views and also to avoid 100s of dislikes for all your good effort. Anyway, my apology for upsetting you emotionally.
@@truthteachers I'm not upset and I appreciate the feedback. As I said they can ask me questions directly if something was confusing and I'd be happy to help. I've helped many. I'm not afraid of dislikes either.
I just care about this stuff because if something is confusing I want to know specifically what and improve on it and also help the person who is confused. Someone just saying "rambling" is not helpful, if they were to say specifically what was confusing or what they didn't understand I would be happy to help.
Either way, thank you 💙
Nothing against you btw :). I understand you are just conveying their views and I appreciate that. There are many complete beginners who took this course and had no issues, so I think it can work for complete beginners. Some things certainly can be confusing and that's why I offer my help to those who need it.
Clients don't need to know how car operaters, all they have to know is to drive
That is true, but it also depends on what kind of car you give to the client. If you give it a well-designed & functional car, the client will be safer. If you give them a car that malfunctions then it's not so safe. So, in the end, it's correct that the client doesn't care how a car operates but they do care that their car is fully functional & operational
@@ProgramWithGio Yeah totally agree. Thank you for reply though
Thank you.
You're welcome