0

Code refactoring python

Query: Code refactor for factory method Actually, I need to refactor code in the getClassObject method Why it is bad in my view? Because default class and base class both are initialized when there is a need to return Specialized class getClassObject This method is kind of factory method and if conditions are in actual a very specific code logic Please suggest a better way to write this code. Feel free to suggest any other point as well https://sololearn.com/compiler-playground/cMopC1T0E2Za/?ref=app

18th Dec 2024, 11:32 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 ответов
+ 1
Ketan Lalcheta , such the use for the method getClassObject you looking for? https://sololearn.com/compiler-playground/c0Jzm5xftvoS/?ref=app
18th Dec 2024, 11:05 PM
Vitaly Sokol
Vitaly Sokol - avatar
+ 1
Thanks but not this way. Object should be constructed of proper class only rather than using super class method from special class Also I cannot combine a b and c related condition as it is computed one by one and very complex than just checking int value
19th Dec 2024, 2:44 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Ketan Lalcheta , I fixed the code, try again, if there are any questions please clarify
19th Dec 2024, 3:15 PM
Vitaly Sokol
Vitaly Sokol - avatar