Factory Method
Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created. Imagine that you’re creating a logistics management application. The first version of your app can only handle transportation by trucks, so the bulk of your code lives inside the Truck class. After a while, your app becomes pretty popular. Each day you receive dozens of requests from sea transportation companies to incorporate sea logistics into the app. Adding a new class to the program isn’t that simple if the rest of the code is already coupled to existing classes. Great news, right? But how about the code? At present, most of your code is coupled to the Truck class. Adding Ships into the app would require making changes to the entire codebase. Moreover, if later you decide to add another type of transportation to the app, you will probably need to make all of these changes again. As a result, you will
/ Design Patterns / Creational Patterns Factory Method Also known as: Virtual Constructor Intent Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created. Problem Imagine that you’re creating a logistics management application. The first version of your app can only handle transportation by trucks, so the bulk of your code lives inside the Truck class. After a while, your app becomes pretty popular. Each day you receive dozens of requests from sea transportation compani
Explore this link on the map →related reading
- Abstract Factoryrefactoring.guru
- Design Patternsgrantslatton.com
- Design Patternsrefactoring.guru
- LEAP 71 | PicoGK.org Blogpicogk.org
- artima - Josh Bloch on Designartima.com
- Favoring Composition Over Inheritance In Java With Examples - GeeksforGeeksgeeksforgeeks.org
- Reading 19: Little Languagesweb.mit.edu
- SOLID Design Principles Explained- Stackifystackify.com
- Refactoring Techniquesrefactoring.guru
- 9. Classes — Python 3.14.6 documentationdocs.python.org
- LEAP 71 | PicoGK.org Blogpicogk.org
- Staterefactoring.guru