C#C
C#2y ago
Nectar

✅ Confused when try to implement Factory Method

I'm learning design patterns starting from the factory method. what I'm confused about is the first initialization to be used as a reference to be manipulated, for example as follows:

https://hastebin.com/share/kohugizayu.csharp

These 3 variables are needed for the movement (and maybe initialization) of the player later and it looks like it should be done in each concrete product, so where should I declare these 3 variables in the factory method implementation? if I declare it in each concrete product it will look like duplication code.

Any suggestions?

Thanks
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Was this page helpful?