Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guidance for monkey patching #355

Merged
merged 9 commits into from
Jul 5, 2022
Merged

Conversation

marcoscaceres
Copy link
Contributor

@marcoscaceres marcoscaceres commented Jan 18, 2022

Closes #184


Preview | Diff

@marcoscaceres marcoscaceres mentioned this pull request Jan 18, 2022
@hober hober requested a review from annevk January 20, 2022 19:53
@kenchris
Copy link
Contributor

This LGTM!

index.bs Outdated
A <dfn export>monkey patch</dfn> layers new functionality on top of an existing specification in a way that extends, overrides, or otherwise modifies the underlying specification's behavior.
Monkey patching <strong>is considered bad practice and should be avoided</strong> for the reasons listed below.

An example of monkey patching would be: specification A defines an algorithm to do something, then specification B overrides or modifies that algorithm with some new functionality.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An example of monkey patching would be: specification A defines an algorithm to do something, then specification B overrides or modifies that algorithm with some new functionality.
An example of monkey patching would be: specification A defines an internal algorithm part of its capability, then specification B overrides or modifies said algorithm with functionality directly, not using publicly defined extension points.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The abstract example is a bit confusing to the reader as it almost implies that no spec should extend another spec. My proposed change could be a good start to make the text a bit explicit. Ideally, we will have examples from the past to illustrate what a monkey patch is and why it is bad. We should also clarify the difference between monkey patching (bad) and modularization (good). Maybe also link to https://en.wikipedia.org/wiki/Monkey_patch

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. My main suggestion is to use the same words throughout for things so it's crystal clear they're about the same thing.

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
marcoscaceres and others added 2 commits January 31, 2022 16:53
Co-authored-by: Anne van Kesteren <[email protected]>
Co-authored-by: Rossen Atanassov <[email protected]>
@marcoscaceres
Copy link
Contributor Author

@atanassov wrote:

The abstract example is a bit confusing to the reader as it almost implies that no spec should extend another spec.

I'll linked to the guidance.

Ideally, we will have examples from the past to illustrate what a monkey patch is and why it is bad.

I'd like to not call out any one spec, but even the example that was originally there is now broken for exactly the reasons we mention in this section:
https://wicg.github.io/web-share-target/#extension-to-the-web-app-manifest

The Web Manifest spec doesn't no longer uses WebIDL, just for starters 🤦‍♀️

We should also clarify the difference between monkey patching (bad) and modularization (good).

I added some preliminary text.

Maybe also link to https://en.wikipedia.org/wiki/Monkey_patch

Linked..

index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
plinss and others added 2 commits July 5, 2022 08:22
Co-authored-by: Amy Guy <[email protected]>
Co-authored-by: Daniel Appelquist <[email protected]>
index.bs Outdated Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
plinss and others added 2 commits July 5, 2022 08:35
Co-authored-by: Lea Verou <[email protected]>
Co-authored-by: Lea Verou <[email protected]>
Copy link
Member

@LeaVerou LeaVerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and @plinss with the changes

@LeaVerou LeaVerou merged commit 06e9a85 into w3ctag:main Jul 5, 2022
@marcoscaceres marcoscaceres deleted the monkey branch July 6, 2022 00:27
hober pushed a commit that referenced this pull request Apr 20, 2023
Co-authored-by: Anne van Kesteren <[email protected]>
Co-authored-by: Rossen Atanassov <[email protected]>
Co-authored-by: Amy Guy <[email protected]>
Co-authored-by: Daniel Appelquist <[email protected]>
Co-authored-by: Lea Verou <[email protected]>
Co-authored-by: Peter Linss <[email protected]>
hober pushed a commit that referenced this pull request Apr 20, 2023
Co-authored-by: Anne van Kesteren <[email protected]>
Co-authored-by: Rossen Atanassov <[email protected]>
Co-authored-by: Amy Guy <[email protected]>
Co-authored-by: Daniel Appelquist <[email protected]>
Co-authored-by: Lea Verou <[email protected]>
Co-authored-by: Peter Linss <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't monkey patch
8 participants