Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created March 14, 2025 10:08
Show Gist options
  • Save trikitrok/80768c8b969472b272dd8167fa3094f3 to your computer and use it in GitHub Desktop.
Save trikitrok/80768c8b969472b272dd8167fa3094f3 to your computer and use it in GitHub Desktop.
Wrap class

Wrap class.

How to do it:

  1. Identify the change point.

  2. Create a class that accepts the class we are going to wrap as a constructor argument.

    • If we have trouble creating the original class in a test harness, we might have to use Extract Interface on the wrapped class so that we can instantiate the wrapper.
  3. Create a method on the wrapper class with tests, that implements the new behaviour.

    • The old behaviour will be called from the wrapper class.
  4. Instantiate the wrapper class in your code in the place where you need to enable the new behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment