Krinkle added a comment.

To avoid reliance on global state, and dragging in the kitchen sink that is IContextSource, a narrow interface called MessageLocalizer should be introduced [..]
Calling code that only needs the msg() method can then start using MessageLocalizer instead of IContextSource [..]
This allows testing and re-use of such components without the need to construct or get an IContextSource from global state.

I think this exaggerates the problem a bit. Creating a Message object requires two things: An interface language, and a title. (Defaults from global User and wgTitle)

When a class doesn't (and shouldn't) involve a context source, you construct Message directly (or wfMessage). When the class has sensible values for these two requirements (language, title), one can create a convenience wrapper by defining a local msg method.

I doubt anyone would extend ContextSource for a class just to get a msg() method. That seems rather unnecessary. I would not consider that acceptable for code in MediaWiki core.

I don't particularly mind a MessageLocalizer interface existing, but want to make sure the rationale is not "Avoiding global state" or "Avoiding context source". The rationale is standardising the method name and parameters with a centralised interface.

I am skeptical of these kinds of interfaces as it usually doesn't end up being used. We'd specify the interface whenever we add such method, but never use it anywhere. It would help to have an example use case where a method would use MessageLocalizer as parameter type, or in what scenario one would want to instanceof-check for it?


TASK DETAIL
https://phabricator.wikimedia.org/T162594

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Ladsgroup, Krinkle
Cc: Krinkle, Nemo_bis, Agabi10, gerritbot, Ladsgroup, Aklapper, daniel, GoranSMilovanovic, Adik2382, Th3d3v1ls, Ramalepe, Liugev6, QZanden, Lewizho99, Maathavan, MuhammadShuaib, Izno, LNDDYL, Psychoslave, Wikidata-bugs, aude, Gryllida, Shizhao, Arrbee, KartikMistry, Mbch331, Jay8g
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to