Associative array or object to save temporal meta-data?

Asked

Viewed 139 times

1

I have a system that will parse web pages, during the process the parser should store some data on the page such as: page type (dynamic, static), size(in bytes) these data on the page should be saved in an associative array ex: $meta_dados[tipo] = 'dinamica'; or in an object? will not be stored in any location this information having so use only during parser

  • Both have their advantages. In my opinion it is more organized with object. By the way, I think the question will be based on opinions after all.

  • I think it depends on the style of your code. If everything is object oriented, it makes more sense to use an object for that as well. The associative array is a wildcard in PHP, serves for anything.

1 answer

2


It goes from the taste of the customer, there is no correct form in this aspect, the best form is the one that serves you. Just try to maintain consistency, if your application has been implemented using object orientation, make a class to maintain metadata. If you are using the procedural form it doesn’t make much sense to place a class to store the metadata but to directly use a variable like the array.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.