1
Ex: In the company where I work they have put in my code a large amount of data that does not need to be in the database, but is not text or actual content. They are a lot of validations and depending on the clause it returns a certain type of content, the problem is that everything is in the same file, which greatly hinders the reading of code, usually in such cases I like to leave the data in a JSON file and only take the necessary one leaving the source code more lean.
Is this practice correct? What would be better?
If you can give an example it would be better. But having static data in a JSON is good practice yes and being in memory (in a variable) is quick to query.
– Sergio
@mikaellemos033 Just this? It has something to do with JSON?
– Maniero
Recently they added a chunk of code like this in my file: if( $x = 'x') { $x = 'test'; $y = 'yteste'; }elseif($x = 'w'){ $x = 'teste2'; $y = 'zteste'; } .... What I usually do is take this play dice on a JSON, and then I just take the dice I make a filter.
– mikaellemos033
@bigown has to do with JSON, because my question is whether this practice is correct, and whether later this could lead to some problem.
– mikaellemos033
Now you’ve put in a bigger chunk of code but I still can’t see the difficulty in doing this with JSON. If it wasn’t JSON it would probably be something else that is being manipulated there. I don’t know if it would make much difference. But it could be. It’s missing context. Somehow I gave a generic answer. Better if you have something more specific.
– Maniero
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero