Page MenuHomePhabricator

Use marker interfaces to distinguish formatters with different output types.
Open, NormalPublic


Formatters that generate plain text, wikitext, and html are not interchangable in the OOP sense. To fix this, all formatters should get marker interfaces that indicate what format they return, so calling code can require that specific interface to be implemented to make sure the formatter actually generate the kind of output that is expected in a given context.

Version: unspecified
Severity: normal
Whiteboard: u=dev c=backend p=0



Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 3:17 AM
bzimport set Reference to bz64366.
bzimport added a subscriber: Unknown Object (MLST).
daniel created this task.Apr 24 2014, 2:50 PM
daniel added a comment.May 7 2014, 8:41 AM

Note that there is one difficulty here: format-agnostic wrappers would need to have one class per output type. E.g. a ConvertingQuantityFormatter that applies unit conversion and then formats the result using some other formatter would need one implementation for each possible output type, e.g. ConvertingQuantityWikitextFormatter, ConvertingQuantityHtmlFormatter, etc.

These could be trivially derived from an (abstract) base class that implements the actual logic, by just adding the respective marker interfaces.

Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).