Last modified: 2014-05-07 08:41:12 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T66366, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 64366 - Use marker interfaces to distinguish formatters with different output types.
Use marker interfaces to distinguish formatters with different output types.
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
WikidataRepo (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Wikidata bugs
u=dev c=backend p=0
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-04-24 14:50 UTC by Daniel Kinzler
Modified: 2014-05-07 08:41 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Daniel Kinzler 2014-04-24 14:50:22 UTC
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.
Comment 1 Daniel Kinzler 2014-05-07 08:41:12 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links