I was making a game (2D RPG) in java using libGDX. Started making classes Top Down aka Thing → Item → Animated Item → DirectionalAnimatedItem → Weapon → MeeleWeapon → MetalMeeleWeapon → Sword → FireSword → SuperFireSword → DeamonsSword. This quickely became a nightmare so I moved everything into nice packages and it became less of nightmare, but still a nightmare none the less. After much refractoring I realized that no class beyond MeeleWeapon was needed. So away they went. I replaced the damage methods with functional interfaces that one could extend and use to set the various methods for functionally of objects and what did when various things …
↧