GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java-design-patterns/factory-method/README.md at master · wangwch/java-design-patterns

Expand file tree

/

README.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
32 lines (25 loc) · 952 Bytes
/

README.md

Copy path

File metadata and controls

32 lines (25 loc) · 952 Bytes
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions
layout pattern
title Factory Method
folder factory-method
permalink /patterns/factory-method/
categories Creational
tags
Java
Difficulty-Beginner
Gang Of Four

Also known as

Virtual Constructor

Intent

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

alt text

Applicability

Use the Factory Method pattern when

  • a class can't anticipate the class of objects it must create
  • a class wants its subclasses to specify the objects it creates
  • classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate

Credits

  • Design Patterns: Elements of Reusable Object-Oriented Software
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.