Don't Use Inheritance To Configure Objects // Python Tips

preview_player
Показать описание


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

I said it in the other video as well, but I really appreciate how you explain what not to do, instead of just what to do. Really helps a lot with regard to writing better quality code.

Sjoerd
Автор

a function to instantiate a class…. a light bulb just went on on my head!! Thanks Arjen

PedigreeGuitars
Автор

If you’re going to define a function that is an object factory, how about making it a classmethod of the class?

That way, it gets subject to normal subclassing behaviour -- when invoked from a subclass, it creates an instance of that subclass, not the base class.

lawrencedoliveiro
Автор

I can't believe you gave a regular zombie 20 more STR than the Evil Overlord... Also EvilOverlord must be singleton. This example is outrageous!

ManInSombrero
Автор

Why do we need the function? Can't we just do zombie = Enemy(params..)?

Chaosman
Автор

I don't really understand the difference between making a subclass that instantiates an object and a function that crates an object... In my opinion, they are the same.

calebparks
Автор

Did you just provide an example of Factory pattern, where a functions returns an instance of a class?

felipealvarez
Автор

Wouldn't it be better to just use a @classmethod inside the enemy's class?

elger
Автор

I have to disagree... I consider you to be more of a BenevolentOverlord()

Shatimmei
join shbcf.ru