Answer the question
In order to leave comments, you need to log in
Hotkeys and class design questions?
All rubbish, I'm with a new portion of nonsense.
I am writing a specific calculator and I want everything to be beautiful, but the question is how reasonable it is, how much it affects performance and whether it is necessary at all. . .
1. Now I'm accessing the class attribute like this class->arr["name"]
, but I want to class->arr->name
, and this is easily done through the __get magic method, but what if I have a multidimensional array ( class->arr->name["attr"]
)? What design to use? What is the best way to pack all this, so that it would be just as beautiful to pick it up from there.
2. What to do in this case:
I have material parameters that do not change, for example, the material and its dimensions.
Is it better to make an array with the name of the material бревно(длина 3, ширина 5, высота 50)
or is it better to create separate arraysБревноДлина 3; БревноШирина 5; БревноВысота 50;
and perhaps it is worth putting such parameters into a separate ini-file?
Thank you!
Answer the question
In order to leave comments, you need to log in
1. don't touch properties directly, use methods.
$obj->getProperty($propertyName); //class->arr["name"]
$obj->getPropertyAttribute($propertyName, $attributeName); // class->arr->name["attr"]
if it's really unbearable - do json_decode(json_encode($a)) - you'll get objects instead of arrays. but it is a pathology.
2. it is better to make an array with the name of the material log (length 3, width 5, height 50).
then disassemble the names of the species LogWidthDoorDogTelegraph is back a pathology.
storing data in ini-files is stsuko original, but it's better not to do that.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question