Questions tagged [OOP] (1357)

2
answers

Why swear?

Recently started to understand the PLO and was immediately faced with the problem Fatal error: Uncaught Error: Call to undefined function add_in_db() in E:\OSPanel\domains\tutorial\index.php:7 Stack trace: #0 {main} thrown in E:\OSPanel\domains\tutorial\index.php on line 7 Here is the code index.php <?php spl_autoload_r...
Timothy_Towne19 asked April 19th 20 at 12:48
2
answers

How to call a class?

Hi. Writing a library for VC, and then the question arose. I want to make it a regular class for working with messages, and an additional class for working with images. Actually, what class should I call? It seems to me that if I want to call VK_Image, and will be called VK (that makes sense rofl), but VK_Image not have a...
cielo.Cartwright asked April 19th 20 at 12:45
2
answers

Is it appropriate to compile a dll with a class inside it?

There is a very convenient Liba (Krat), I want to write over it a wrapper simplifying a lot of the routine and give in the form of a dll for writing software in c++. The pros have been uploaded yet class for working with him. Googled - like you, but (honestly) don't want to go and to stumble on a rake for nothing. How diffi...
Kameron_Grimes7 asked April 19th 20 at 12:35
3
answers

Can you give an example of when to use private and when protected?

I'm here until the end can not understand the advantages of using the private access modifier is protected. After all, one of the principles of SOLID States that in order to change something in the class, no need to change the code - you need to do it through inheritance. Is it possible in this case to use protected? Can y...
dorthy_Ebert41 asked April 19th 20 at 12:29
1
answer

How to pass an argument to a function object of a class inside its private method?

I created a CRUD model for the database table in the form of Active Record. If the validation and saving of some fields in the models execute additional operations. The class was quite large. To make the architecture of the code more understandable, I have divided some of the fields into groups and made their logic in a sep...
Alice.Ebert asked April 19th 20 at 12:11
2
answers

Whether the object in this example?

class Book { public $name; public $price; public function __construct(string $name, int $price){ $this->name = $name; $this->price = $price; } } $a = new Book('Name', 1000); $stmt = $db->prepare("INSERT INTO `books` (`name`, `price`) VALUE (?, ?)"); $stmt->execute(array($a->name, $a->price)); It...
Jeramie.Romague asked April 18th 20 at 13:32
1
answer

How to implement dependency (composition) and depend on the interface?

For example there is such code: class A { private $b; public function __construct() { $this->b = new B(); } } class B { // ... } because class A has a dependency on class B, for this use composition to deleting the class And deleted all its dependencies. But you need to make it so that you can easily replace t...
Rosie.Langworth asked April 18th 20 at 12:48
1
answer

How to create objects in python?

If by Sisney type function we create types(classes), then by what are the features of an instance of any class type? For EXAMPLE: True — the object itself (an instance of) class <class 'bool'> — which in turn is of type <class 'type'>
nakia_Cremin asked April 18th 20 at 12:45
1
answer

How to combine a relational model database with the PLO?

There are two classes: Products and Brands. Both the idea needs to be independent, if not for the fact that the Product is field brand_id. Came to mind to connect them in the intermediate class Collections. Enumeration objects. Does the idea of relational databases with OOP are incompatible? Or still modifierade further cla...
eusebio.Carter asked April 18th 20 at 12:45
2
answers

The correct use of the principles of DDD, and how to replace the Repository?

In the XML file stores the users, to be displayed in the pattern list all users with the ability to view detailed information. To do so, first I created a user entity UserEntity, which contains only private properties + getters in the constructor I pass all user data. Next, I created a collection UserСollection, to work w...
george.White82 asked April 18th 20 at 12:38