vendredi 25 août 2017

Is this a good case for the Strategy Pattern

I have the following inputs:

  1. A CSV File
  2. An array of grammar rules. The grammar rules are
    basically metadata that tells me what which each column datatype
    should be.

The output would return back to me a list of records that had any errors. So if column should be a date but I'm given the wrong format. I would return those rows.

The csv file would be something like this:

first_name,last_name,dob,age,
john,doe,2001/05/02
mary,jane,1968/04/01

Metadata:

column:first_name
type:string

column:dob
type:date

I was wondering if the strategy pattern would be the right choice. I was thinking of injecting the proper grammar (metadata) depending upon the file. I have multiple files I want to validate.

Aucun commentaire:

Enregistrer un commentaire