In a situation, where you need to generate a bunch of <title>
, <meta name="description">
and <h1>
tag contents, based on many query search parameters for thousands of pages. What principle or pattern is best fit in a situation like that?
For example:
You will get some array with lot's of query parameters, like the type of some object, it's features, location and many more. Based on the parameters, you need to generate, translate and render, different content in tags. What to do to avoid too many if statements and switch cases.
I am aware that I could replace conditional with polymorphism, but still, when I get all those parameters, I need to somehow check for all possibilities and determine context what I will use. Then I am faced with a bunch of if statements, checking is some value set, what value does it have etc. Too many condition checking. Basically, that array I get is my huge problem, because I have to check every value if it exists or not. Unfortunately that params that come in an array shape, can't be turned to the class. So I have to stick with an array.
Thanks.
Aucun commentaire:
Enregistrer un commentaire