Do You Really Know PHP Class Visibility Scopes?

  Рет қаралды 1,449

Mark Shust

Mark Shust

Күн бұрын

Visibility scopes in PHP classes often trip up even experienced developers. Learn the key principles you need to avoid major pitfalls.
This quick video will explore how public, private, and protected scopes function in OOP classes and subclasses. Master visibility and take your PHP skills to the next level!
00:00 - Introduction
00:58 - Public Visibility
02:00 - Protected Visibility
03:42 - Private Visibility
05:25 - When To Use Each Visibility
LINKS FROM THE VIDEO
=======================================
🐘 PHP 101 Course - m.academy/courses/php-101/
WANT TO LEARN MAGENTO?
=======================================
🏫 Learn Magento at M.academy - m.academy
🎓 M.academy University - m.academy/university/
FOLLOW ME
=======================================
🧑‍💼 LINKEDIN: / markshust
🐙 GITHUB: github.com/markshust
🐦 TWITTER: / markshust
#php #oop #opensource

Пікірлер: 13
@11cHIP1
@11cHIP1 6 ай бұрын
Great idea to describe how the concept applies in the context of most known CMSs/Frameworks, I liked it
@MarkShust
@MarkShust 6 ай бұрын
Thanks a bunch! I'm glad you enjoyed the video and the way I explained the concept with CMSs/Frameworks
@totex1979
@totex1979 6 ай бұрын
I already know this, but still a good refresher. Thank you!
@MarkShust
@MarkShust 6 ай бұрын
Glad it was helpful! I personally like refreshers like this as well. So much to learn & remember!
@user-rd2ws7wl7x
@user-rd2ws7wl7x 6 ай бұрын
You're making Magento better
@MarkShust
@MarkShust 6 ай бұрын
Appreciate it!
@bharathkumarj2513
@bharathkumarj2513 6 ай бұрын
Hi there , can you also make videos on php interfaces and abstraction please ?
@MarkShust
@MarkShust 6 ай бұрын
Adding it to the queue Bharath 🙌
@bharathkumarj2513
@bharathkumarj2513 6 ай бұрын
@@MarkShust your a gem 💎
@kamilmaliszewski7942
@kamilmaliszewski7942 6 ай бұрын
Yeah, but in Magento world there is a one problem. Only "public" methods can be used in "plugin" feature. When you want to make very flexible module you need to use this "public" very often. So normally you would use protected, but you think that there is a nice place to hook by plugin, so you need to change it to "public". I don't like this approach, but as Magento developer I appreciate when I can change some functionality by plugin and I don't need to use patches or override file by "preference".
@MarkShust
@MarkShust 6 ай бұрын
Hi Kamil, in actuality, you really shouldn’t be using public too often within Magento code. I used to use it for everything but changed my mind after seeing tons of plugins being used, overly used, leading to spaghetti architecture. you really only want to expose those methods that others may need to modify, not your private/protected underlying business logic code. This actually isn’t a restriction of Magento - it’s the pattern for any sort of software that uses plugin-like architecture. The generated code, which makes these plugins work, uses inheritance to write the code that makes plugins possible, due to the reasons in this video.
@kamilmaliszewski7942
@kamilmaliszewski7942 6 ай бұрын
​@@MarkShustof course! But in reality very often u need to change this "closed logic", cause business wants it. I started using `composer patches` for it and I think this approach is great. It protects you while you're doing upgrade -> when parent module is changed, then patch will fail and there is a clear information that you need to rebuild your patch.
@MarkShust
@MarkShust 6 ай бұрын
@@kamilmaliszewski7942yea it's totally a balance. But I think 3rd-party module devs need to weigh out the situation and realize when a developer will need to modify code, and to architect it appropriately, and therein lies the issue -- they rarely do this. So it's not really a problem with the architecture, but a lack of competence in design and realizing the needs of programmers.
Beginning Programmer? STOP Overwhelming Yourself
9:39
Mark Shust
Рет қаралды 745
I Quit Magento. Here's Why I Came Back.
13:29
Mark Shust
Рет қаралды 1,4 М.
Китайка и Пчелка 4 серия😂😆
00:19
KITAYKA
Рет қаралды 2,5 МЛН
I Need Your Help..
00:33
Stokes Twins
Рет қаралды 157 МЛН
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 56 МЛН
Super gymnastics 😍🫣
00:15
Lexa_Merin
Рет қаралды 18 МЛН
Magento 2 Nightmare? My 5 Reasons to Avoid It
8:21
Mark Shust
Рет қаралды 1,2 М.
How to answer any system design interview question?
1:37:51
Design Gurus
Рет қаралды 3,1 М.
microsoft's new AI feature is an absolute dumpster fire
9:34
Low Level Learning
Рет қаралды 56 М.
Blindly Following Magento Best Practices? STOP NOW
10:48
Mark Shust
Рет қаралды 920
Should You Learn Object Oriented PHP?
13:48
Dani Krossing
Рет қаралды 10 М.
Are Magento Dev Interviews Failing? Let's Fix Them
12:25
Mark Shust
Рет қаралды 1,7 М.
What Happened to All the Magento Developer Jobs?
8:06
Mark Shust
Рет қаралды 7 М.
The Magento Community, Ecosystem, MM23NYC & more
52:57
Mark Shust
Рет қаралды 743
OOP PHP |  Namespaces in PHP #19
13:25
Bitfumes
Рет қаралды 40 М.
Китайка и Пчелка 4 серия😂😆
00:19
KITAYKA
Рет қаралды 2,5 МЛН