Mid OOP

What are abstract factory patterns and how do abstract classes/interfaces fit in?

  • Abstract Factory creates families of related objects.
  • Interfaces/abstract classes define product contracts, factories implement them.

interface IButton { void Render(); }

class WinButton : IButton { public void Render() =>

Console.WriteLine("Windows Button"); }

interface IGUIFactory { IButton CreateButton(); }

class WinFactory : IGUIFactory { public IButton CreateButton() =>

new WinButton(); }

More from C# Programming Tutorial

All questions for this course