Page MenuHomePhabricator

Consider transform naming convention
Closed, ResolvedPublic2 Estimated Story Points

Description

Rename JavaScript, CSS, and test fixtures to use 'verbNounTransformer' pattern:

  • WidenImageTransformer
  • CollapseTableTransformer

As part of this effort:

  • Rename "kick off" method to "transform" or "transformSomething"
  • Update the readme with the established convention
  • Bump the major version
  • Update doc to call out 'verbNounTransformer' pattern
  • Update the changelog with each breaking API change so that integration is very easy

Event Timeline

I noticed this in your iOS implementation and immediately liked it better. This is an unquestionable improvement over the current naming but let's try to think if there's even better names in light of all the modules identified in the audit. If not, I'm all for these names! Way to go!

@Mhurd, for example, what should we call the transform for lazily loaded images? I was thinking LazyImageTransformer. I kind of like the idea of using a Transformer suffix on everything or at least a common suffix of some kind since we have so many transforms.

Mhurd updated the task description. (Show Details)
Mhurd updated the task description. (Show Details)

@Niedzielski

What if we just name the files by noun, then the functions themselves are the verbs?

Then it reads really nicely. For example, on iOS it would read like this:

wmf.links = require('wikimedia-page-library').links
wmf.paragraphs = require('wikimedia-page-library').paragraphs
wmf.images = require('wikimedia-page-library').images

...and...

window.wmf.links.hideRedlinks( document );
window.wmf.paragraphs.moveFirstGoodParagraphUp( document );
window.wmf.images.widenImages( document );

@Mhurd, I like it! What do you think about keeping the modules tho? Like:

const paragraphCollapseTransformer = new transform.paragraph.ParagraphCollapseTransformer()
paragraphCollapseTransformer.transform(document)

const paragraphRelocationTransformer = new transform.paragraph.ParagraphRelocationTransformer()
paragraphRelocationTransformer.transform(document)
Mhurd claimed this task.