Skip to content

Conversation

@ilopX
Copy link
Collaborator

@ilopX ilopX commented May 20, 2022

Abstract Factory Pattern

Abstract Factory is a creational design pattern that lets you produce families of related objects
without specifying their concrete classes.

Tutorial: here.

Online demo:

Click on the picture to see the demo.

image

About

image

Diagram:

image

Client code:

class App {
  void addShape(double x, double y) {
    final newShape = activeToolFactory.createShape(x, y, activeColor);
    shapes.add(newShape);
  }
}


class PropertyPanel extends StatelessWidget {
  final PropertyWidgetFactories factories;

  @override
  Widget build(BuildContext context) {
    return Row(
        children: propertyWidgetFactories
            .createListWidgetsFrom(activeToolFactory.properties)
            .toList(),
      );
  }
}

@ilopX ilopX merged commit 39be84b into RefactoringGuru:main May 20, 2022
@ilopX ilopX deleted the add-properties-to-tool-factory branch May 20, 2022 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant