lundi 29 janvier 2018

What design pattern to apply for case?

I have a table with over 100 columns. Clicking on each column header I can filter by provided parameters.

For example, clicking over header: name the input field is appeared allows to filter by name.

So, it can be different filter, by one field and some composite fields.

I tried to avoid linear case using if conditions like:

if($type == "name") {
   //
} else if ($type == "age") {
  //
}

I think it should be strategy and factory pattern to create instance of concrete search class? What do you think?

Aucun commentaire:

Enregistrer un commentaire