A
A
Anton R.2019-08-26 21:35:04
PHP
Anton R., 2019-08-26 21:35:04

How does the data get into the class?

Another elementary question on the way of studying OOP, which is not directly discussed anywhere in practice (at least in an accessible language), namely, how does a class get its data for work?
That is, there is a certain class, it has several private variables - data that methods will work with, so far I have defined several ways how Data gets into the class:
1. Through the Constructor
2. Through setters
3. Directly after creating the class (if the variable public), like this: $class->value = 'Value';
...
How else?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
T
ThunderCat, 2019-08-26
@ThunderCat

1. Through the Constructor
2. Through setters
3. Directly after creating the class (if the variable is public), like this: $class->value = 'Value';
4. Load from external storage(AR)
5. via DTO

D
Dmitry Derepko, 2019-08-26
@xEpozZ

deserialization, __set_state

G
Gomonov, 2019-08-26
@Gomonov

cloning

A
AlexBergal, 2019-08-27
@AlexBergal

Reflection

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question