dimanche 4 août 2019

Factory design pattern (different signature)

Good day

enter image description here

I would like to implement design according to code snippet below:

foreach {
...
    var converter = _convertorsFactory.create(params)
    var result = converter.Convert(string: value)
...
}

  • The factory should create formatter base on input parameter.
  • Formatter should apply method 'Convert' to convert string value to desire output type

Main challenge for me that 'Formatters' have different 'convert' method signature (different return type). Thus what signature should be factory 'create' method?

Quotation: Thus, please help me to handle what design more suitable in such situation

Aucun commentaire:

Enregistrer un commentaire