Ads skipped

The Factory Pattern in Python // Separate Creation From Use

205K views · Jul 16, 2021 · Education

Comments · 265

  • @ArjanCodes · 2 years ago · pinned

    💡 Here&apos;s my FREE 7-step guide to help you consistently design great software: <a href="https://arjancodes.com/designguide">https://arjancodes.com/designguide</a>.

    1

  • @johnstanley1993 · 5 years ago

    For me as a data scientist your videos really stepped up my software development game. The Factor Pattern together with having abstract classes as interfaces is something I immediately applied in my current project. This is not something you typically learn in data science courses, even though I think this is crucial when willing to write code in a professional context. Thanks Arjan for sharing those valuable insights!

    103

  • @yaczesuaff · 5 years ago

    I&apos;m binging your videos currently and (among other things) there&apos;s something I love: the examples are meaningful. They are practical, solve actual problems. Not your another off the mill tutorial with generic class C inheriting class B etc. Seeing that your example applications mimic actually doing something, makes it 100x easier to wrap the application logic and focus on the topic at hand. I&apos;m amazed.

    16

  • @VCR47527 · 4 years ago

    Unsure if this is mentioned somewhere, but this is the GOF Abstract Factory pattern. Not to be confused with the GOF Factory Method pattern. The Abstract Factory pattern&apos;s goal is, as Arjan says, for grouping different class instantiations together. The Factory Method pattern is about extending the functionality of a class.

    57

  • @002uzumaki · 5 years ago

    I just found out about you today while learning certain design patterns. Now, I started reading about factory patterns just a few hours ago and boom, you&apos;re here with the video. Thanks for the video. Maybe adapter pattern in the next video?

    45

  • @richarddanipog4975 · 1 year ago

    Finally, a video that explains the factory pattern well and clearly. Thank you very much I so enjoy your presentation and delivery!

    1

  • @AsenovMiroslav · 3 years ago

    I would like to propose the use of a factory dictionary approach, where the dictionary values store class names instead of actual instances. This can be more efficient, especially when creating instances is resource-intensive. The idea is to define a dictionary of factories like this:<br><br>factories = {<br> &nbsp;&apos;one&apos;: FactoryOne,<br> &nbsp;&apos;two&apos;: FactoryTwo<br>}<br><br><br>Later, when you need to create an instance based on a specific key, you can use the stored class names to instantiate the desired objects. This is done as follows:<br>return factories[key]()<br><br>With this approach, you optimize memory usage by storing class names, and actual instances are only created when needed.

    4

  • @ytlagu2010 · 4 years ago

    I really like the idea where you first present the problem and show the solution. Most videos I watched rant about the theory but forgets to tell you the why part.

  • @cabanford · 5 years ago

    I so enjoy your presentation and delivery. Great job in explaining &quot;why&quot; things are used and not just the typical &quot;how&quot; (which is what geeks who already grokk something tend to do). <br><br>I also like how you discuss what things a pattern doesn&apos;t do well and then you provide an alternative for such cases. ⭐⭐⭐

    9

  • @JonMartins · 5 years ago

    I&apos;m addicted to your channel man!<br>Congrats. Cheers from Brazil.

  • @9boss6 · 5 years ago

    Thank you for what you are doing. It is really helpful. Keep going.

    4

  • @mdunkman · 5 years ago

    I really enjoyed the video. Your pacing and amount of content is very good as a reference!<br><br>In a future video, could you clarify the differences between a Factory Pattern and a Builder Pattern? I feel like the builder is a way to collect factories, but I would enjoy seeing a worked example.

    8

Up next

LIVE

The Factory Design Pattern is Obsolete in Python

ArjanCodes · 116K views

LIVE

Uncle Bob’s SOLID Principles Made Easy 🍀 - In Python!

ArjanCodes · 357K views

LIVE

Don’t Use Boolean Flags in Python, Use Policies Instead

ArjanCodes · 165K views

LIVE

What does '__init__.py' do in Python?

Tech With Tim · 357K views

LIVE

Python Design Patterns Tutorial for Beginners 2022

miss google · 15K views

LIVE

Factory Method Pattern in Python: Creating Objects with Ease

campbelltech · 5.7K views

LIVE

QUESTIONABLE Object Creation Patterns in Python 🤔

ArjanCodes · 77K views

LIVE

! Python design patterns masterclass

CodeTekTeach · 34K views

LIVE

Let's Take The Adapter Design Pattern To The Next Level

ArjanCodes · 56K views

LIVE

High-performance Database Architecture - An Interview with Tyler Cloutier

Molly Rocket · 124K views

LIVE

How to Implement the Strategy Design Pattern in Python

ArjanCodes · 59K views

LIVE

Factory Method Pattern – Design Patterns (ep 4)

Christopher Okhravi · 613K views

LIVE

How To Reduce Coupling With Facade | Design Pattern Tutorial

ArjanCodes · 48K views

LIVE

The Builder Pattern in Python: Finally Explained!

ArjanCodes · 65K views

LIVE

MCP vs API Explained: Do You Really Need MCP?

KodeKloud · 238K views

LIVE

HashMaps in Python Tutorial - Data Structures for Coding Interviews

Codebagel · 309K views

LIVE

Music for Work — Deep Focus Mix for Programming, Coding

Chill Flow · 2.4M views

LIVE

7 Design Patterns EVERY Developer Should Know

ForrestKnight · 1.3M views

LIVE

How to use the STRATEGY PATTERN in Python

Coders Bring Change · 5.4K views

LIVE

Pydantic Tutorial • Solving Python's Biggest Problem

pixegami · 514K views

LIVE

Learn MCP Servers with Python (EASY)

Alejandro AO · 148K views

LIVE

Two UNDERRATED Design Patterns 💡 Write BETTER PYTHON CODE Part 6

ArjanCodes · 74K views

LIVE

Solving A Common Issue With The Strategy Pattern // In Python

ArjanCodes · 52K views

LIVE

10 Important Python Concepts In 20 Minutes

Indently · 1.6M views

LIVE

Python Tutorial: Working with JSON Data using the json Module

Corey Schafer · 1.3M views

YouTube, with the door locked.

Aegis plays a clean stream instead of YouTube's player, so pre-roll ads, trackers, and fingerprinting never ride along. Drop Shields any time if you want the official player back.