From the course: C#: Design Patterns Part 1

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Factory Method pattern to choose the implementation of an action dynamically

Factory Method pattern to choose the implementation of an action dynamically - Python Tutorial

From the course: C#: Design Patterns Part 1

Factory Method pattern to choose the implementation of an action dynamically

- [Instructor] We've already used a simple factory method as part of the iterator. But let's create another sample usage of it to get more perspective on other situations for the factory method. I've created another new console project. You can do that or start with the project from GitHub. It's in the factory folder. Again, I'll be putting everything in the same file to keep the overall picture simple. But don't do this outside of demo land. Let's imagine an application that needs to let users know that some event has happened. Say, for example, their order has been shipped. I don't want to actually email users while I'm debugging the application and I know that future versions of the application are going to need new ways to notify a user. So I'm going to start by encapsulating the notify user functionality with an IUserNotifier interface. It does one thing, notify a user. We'll have it take a user ID. Let's…

Contents