Skip to content

Instantly share code, notes, and snippets.

@danveloper
Last active December 17, 2015 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danveloper/5672589 to your computer and use it in GitHub Desktop.
Save danveloper/5672589 to your computer and use it in GitHub Desktop.
Bettering - "Redefining the Service Layer with Groovy Categories"
class CheckPaymentProcessor {
static String process(PaymentType paymentType) {
def gateway = new CheckPaymentProcessor()
// … implementation code ...
}
}
class EmployeePaymentProcessor {
static String process(PaymentType paymentType) {
def gateway = new EmployeePaymentGateway()
// … implementation code ...
}
}
class GiftCardPaymentProcessor {
static String process(PaymentType paymentType) {
def gateway = new GiftCardPaymentGateway()
// … implementation code ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment