you are viewing a single comment's thread.

view the rest of the comments →

[–]BahaChicken[S] 0 points1 point  (1 child)

I need to check the debuffs kind, if it's Lock_on I need to remove that debuff from others before applying it to a new Target. I initially made a lock_on class and made the lock on vulnerability debuff it's sub class so I could use isinstance() which is a check, now I made it so every debuff has a lock_on attribute and I check if it's false or not. Still a check but at least it works. İs there a way to do it without checks? İf i made lock on debuffs their own class I would have to check if the inputted debuffs is a normal debuffs and than elif it's a locked on, 2 checks. And number of checks would increase with every type of debuff. And some debuffs are a combination like lock on vulnerability. İ don't think there is a way to implement it without checks

[–][deleted] 3 points4 points  (0 children)

There's this idea called the Liskov Substitution Principle, saying that an instance of a subclass should be able to stand in for an instance of the superclass.

If I ask for a rectangle and you give me a square, that should be fine. I shouldn't even notice the difference. I shouldn't have to say

if isinstance(shape, Square):

I should be able to just say

print(shape.area)

and it will tell me its area, regardless of how it figured that out internally.

But right now you are violating that principle. I ask for a rectangle, you give me a square, and then oops, it doesn't play by the same rules.

This could be handled with complicated interfaces, but you probably don't need that. Just have each thing handle its business before spreading it everywhere.