Answer the question
In order to leave comments, you need to log in
How to understand OOP PHP library?
We have https://github.com/danog/MadelineProto
a bunch of files divided into subfolders. How to start litigation? In which file is what stored and how is it organized?
I know that OOP is about creating classes, using objects, etc. I write in a class myself, but it's more of a collection of boolean methods with convenience properties and __construct - which is probably not true OOP. Understanding how to do inheritance does not yet help to use it. :(
How do you immediately understand how to use someone else's code? What algorithm do you use? Questions are not for a beautiful word - a real great desire to understand. Please do not pass by.
ps1
In the case of simple functions where they write what is at the input and output, everything is clear. Is it easier to maintain the documentation of the OPP than the documentation of specific functions? If in the future there was a service like github but for functions and they were put in php as easy as installing packages apt install function1 function2 ..; it would be just chicdos. Not?
ps2
The author of the library deliberately omitted several files that the user must create himself, such as not for fools. Is this a conscious, healthy modern approach, or is the author just being rude? https://github.com/danog/MadelineProto/issues/33#i...
ps3
Also an OOP library from facebook https://facebook.github.io/php-webdriver/latest/in... considered well documented, I saw it right, 5 seconds and the code is ready? Or how?
For my tasks it is clear how to use it, just wondering if this is the crown of descriptive detail in the world of OOP or could it be better?
Answer the question
In order to leave comments, you need to log in
Dude. Any code (library, package, function) - there is some promise of its manufacturer to do something valuable for you. This description must give the name of the class and its method that this result will create. And then - it's not your problem how everything is arranged inside. You create an object, give it something it depends on, and call a method on that object. All!
Imagine a TV. Its manufacturer promises to give you the opportunity to watch TV channels if you connect an antenna. What is your task as a TV user? Correctly! Insert the antenna and press the power button. After all, you will not climb inside the TV with a tester and check how everything is arranged there. The description should tell you where the power button is.
If you use a package (module, library) in which it is not immediately clear, then this is not your problem, but the manufacturer who created it. It's just that they probably didn't come up with anything better, and you either have to create it yourself or use such a G...
The code should be something like this:
$tv = new Tv(new Antena);
$content = $tv->on();
This is what OOP is.
How to start litigation? In which file is what stored and how is it organized?
// Так
$someObf = new SomeClass('this_is_example_api_key');
// Или так
$someObf = new SomeClass(require('config.php')['api_key']);
// Или, например, так
$someObf = new SomeClass($config->get('api_key'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question