Factory Design Pattern - Advanced Python Tutorial #7

preview_player
Показать описание
In this video we talk about the factory design pattern in Python.

◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚

💻 Exclusive Content 💻

🌐 Social Media & Contact 🌐

Рекомендации по теме
Комментарии
Автор

For factories I prefer to use a dictionary with the key strings and the value being the class in the build_person to avoid the cost of comparison as follows
def build_person(person_type):
PERSONTYPES = {"Student":Student, "Teacher":Teacher}
return PERSONTYPES[person_type]().

abebuckingham
Автор

That is probably how you would do that in Java. But in Python we just use a function that returns the object.
You can already see that because you made it a staticmethod, and a class with just one function (and even worse a staticmethod), is a clear indicator that it should be a function, not a class.

alexd
Автор

I was trying to understand this topic since past one week and watching multiple videos was making me more and more confused. I understand it through this video. Thank you for explaining so well in this video.

mr_robot_tech
Автор

These pattern tutorials are gud, please we need more and eventually creating a project with one

raymondmichael
Автор

You proved programmers can also have biceps 💪

manifaridi
Автор

The clarity of your explanation/example of the factory pattern is awesome!!!

kevinjones
Автор

Explained with such a simple way without complicating anything. Awesome!!

bhaveshvaishnav
Автор

Hey man, I know you don't have a lot of views yet, but when programming becomes a core subject in schools, you'll be the khan academy of the future. Keep on the grind G

iiStxrii
Автор

Thanks for all the valuable videos, supported you by buying all the seven books. :)

ptyspawnbinbash
Автор

You’re unbelievably cool! Keep up the good work!

pythonisthebest
Автор

You need always self in a object, because self, it the object itself, to use all attributes or methods, over "self.".
Cheers from Germany.

ddjambel
Автор

can anyone tell me difference between Factory Design and Abstract Factory Design ?

dpm-
Автор

Having the if-else logic still reside in the ConcreteFactory violates the Open-Closed Principle. Would it be better to have an interface for FactoryPerson and implement Student and Teacher from it?
If so, how would that implementation look like?

deeprony
Автор

Which text editor are you using bro???

Custom-Tkinter
Автор

I'm really liking this advanced python you please make a video describing what meta classes and how they work?

hasibislam
Автор

that was a really nice and simple example man. thank you so much. cleared up my understanding of a factory design pattern

golammuhaimeen
Автор

instead of hardcoding "student" and "Teacher" values, you can use an ENUM

heroicrhythms
Автор

Great Tutorial. Part 2 of Vim course next =)

jerielmorales
Автор

Great explanation as usual. I'm defintively a rookie on OOP, but I'm learning a lot. Thanks !

jrgomez
Автор

helpfull, thanks, I'd rethink the use of conditions in factory

gauffr