Skip to content

Latest commit

 

History

History

conceptual_platform_dialog

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Abstract Factory pattern

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.

Tutorial: here.

About example.

This the very conceptual example rewrite from original source code java example

Diagram:

image

Client code:

late Dialog dialog;

void main() {
  configure();
  runBusinessLogic();
}

void configure() {
  if (Platform.isWindows) {
    dialog = WindowsDialog();
  } else {
    dialog = HtmlDialog();
  }
}

void runBusinessLogic() {
  dialog.renderWindow();
}

Output:

Windows Button
Click! Button says - "Hello World!"