Using getter and setter accessors in object oriented programming, and creating them with PhpStorm. (see shortcuts below to key points) In this programming tutorial Adam Culp of Beachcasts php programming videos shares some good and bad points about using getters and setters in object oriented programming, and shows how to automatically create them from within PhpStorm.
Please * LIKE, COMMENT, AND SUBSCRIBE * – and share with others!
Key Topics:
– Good reasons to use getters and setters
– Bad reasons not to use getters and setters
– How to create getters and setters automatically in PhpStorm
For a nice list of equipment I use in my studio, and to support the channel if you make any purchases (doesn’t cost you a thing), visit my kit at kit.co: https://kit.co/beachcasts/beachcasts-studio
Errata:
Let me know if you notice anything that should be errata
Associated Links:
https://pragprog.com/articles/tell-dont-ask#SHARP – Ask, don’t tell
https://www.jetbrains.com/help/phpstorm/generating-code.html#generate-getters-setters
Timeline:
00:00 Video Intro
01:28 reasons to use getters and setters
01:34 separation of concerns and consumers
02:02 code maintainability benefit of getters and setters
04:50 tell, don’t ask object usage
06:45 use the object rather than the data
07:38 lazy loading gained by getters and setters
08:00 memory management aided by getters and setters
08:21 debugging also possible with getters and setters as inception points
08:36 interoperability between libraries helped by getters and setters
09:01 setters and getters are available for overriding through extension
09:38 lambda expressions also easier through usage of getters and setters
09:49 access levels of getters and setters are possible
10:17 getters and setters may reveal implementation details through convention
11:00 if no data manipulation required, then why use getters and setters?
11:20 if class and fields are public, why limit access to fields with getters and setters?
12:10 PHP version 7.4 will have typed properties, so setters and getters may not be needed
13:25 example of using PhpStorm to create getters and setters automatically
Other Beachcasts videos you might find interesting:
Critical programming issues preventing a PHP 7 upgrade https://youtu.be/z13glyDnm6s
Behat for beginners functional REST API testing tutorial https://youtu.be/nFNGDhyFrm4
Doctrine ORM one-to-many bi-directional association https://youtu.be/4nEdBDxBc1w
PHP Mess Detector static analysis to find PHP code smells https://youtu.be/8fEfHESrK5E
Doctrine ORM one-to-many self-referencing association https://youtu.be/4dHZ6cZooOk
10 reasons to become a consultant in a consulting business https://youtu.be/J7gpMYAKmDM
Zend Framework becomes Laminas project at Linux Foundation https://youtu.be/CEIO90ocEDI
10 bad things about consulting https://youtu.be/ELE0G3e7h3c
How to get lines of code in PHP https://youtu.be/HpC-Cvxj6oY
Make a List handler middleware https://youtu.be/VLqavHCFv6g
Make a Delete handler middleware https://youtu.be/3nLbQfMk99k
Make an Update handler middleware https://youtu.be/3Zcq5Jjz1Po
Use UUID with Doctrine ORM for DB keys https://youtu.be/SYuLwMwSIpg
Make a Create handler middlware https://youtu.be/FIYh-VIWUko
Automate Hypermedia creation for PHP REST API https://youtu.be/dX6S-pJVUXI
Learn about Hypermedia and how to create it https://youtu.be/aV6ro_JXL_A
Doctrine ORM Paginator for PHP REST API https://youtu.be/UpqOew4sNT0
Doctrine ORM Entity how to https://youtu.be/NnK9Geg1h_E
Configure Doctrine ORM https://youtu.be/pFvh5ZNhdOQ
Create PHP middlware with Zend Expressive https://youtu.be/26440j7D0BE
Configure PhpStorm for PHP development with Docker https://youtu.be/FQWL-JTZvf4
Create PHP development environment with docker https://youtu.be/2ESAi2vq-80
Help through referrals:
Thinking of buying a Tesla electric vehicle? Use this referral link to also get six months of free Supercharging for both of us. Thank you. https://www.tesla.com/referral/tanya21367
I use TubeBuddy to help me manage my YouTube channel. If you’re interested, click the following link to check it out. https://www.tubebuddy.com/beachcasts
#oop #gettersandsetters #beachcasts


Comments