1

I´m using a framework for javascript to display beautiful alert boxes. This framework uses another framework to actually display the boxes. So it´s something like that:

 let showAlert = function (type, message, title) {
    opts = {};
    opts.title = title;
    opts.type = type;
    opts.confirmButtonText = 'Confirm';
    opts.text = message;

    return swal(opts); // here it uses the concrete component sweet alert
};

messageFramework.success = function (message, title) {
    return showAlert ('success', message, title);
};

messageFramework.error = function (message, title) {
    return showAlert ('error', message, title);
};

So the client uses the messageFramework abstraction, but the messageFramework uses the swal function of the sweet alert implementation. The message framework is a wrapper or an adapter?

Thanks.

1

1 Answer 1

1

Wrapper can stand for several types of design patterns:

  • Adapter allows classes with incompatible interfaces to work together by wrapping its own interface around that of an already existing class.
  • Decorator dynamically adds/overrides behaviour in an existing method of an object.
  • Facade provides a simplified interface to a large body of code.

Of these, I feel like Facade best fits what this is doing, with Adapter being second best but also fitting.

1
  • I dont think it´s an adapter because it wraps other framework, it´s coupled by using the sweet alert concrete imp.
    – gog
    Commented Jan 24, 2019 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.