Skip to content
Sharp

Design patterns · interview question

You are tasked with implementing a system for creating different types of shipping methods in an e-commerce application. What is the primary benefit of using the Factory Pattern in this scenario?

Multiple choiceMediumchapter-13-curatedpremiumdesign-patternsfactory-pattern
Choose one answer
Answer and explanation

Correct answer

A. It allows for easy addition of new shipping methods without modifying existing code.

Why

The Factory Pattern provides a way to introduce new types of shipping methods by allowing the addition of new classes that implement a common interface, thus adhering to the Open/Closed Principle.

Test yourself on Design patterns

A free test with instant, explained results. No account needed.

Start free test
All Design patterns questions →