For example.
Look at this class hierarchy:
public abstract class CharacterEquipment
{
protected abstract void RunBeforeAttachProcedure();
protected abstract void AttachToCharacter();
protected abstract void PlayEquipEffects();
public void Equip()
{
RunBeforeAttachProcedure();
AttachToCharacter();
PlayEquipEffects();
}
}
public abstract class CharacterBackEquipment : CharacterEquipment
{
protected override void AttachToCharacter()
{
// Attach procedure that never changes for the back.
}
}
public class CharacterJetpack : CharacterBackEquipment
{
protected override void RunBeforeAttachProcedure()
{
// Position jetpack so it is at the right position to attach to the character's back
// There can be other equipments that you can attach to the character's back like a normal backpack which would need slightly different positioning and rotation
}
protected override void PlayEquipEffects()
{
// Play jetpack equip sounds and particle effects
}
public void ActivateThrusters(float force)
{
// This is new functionality introduced, now the equipped jetpack can fly
}
}
Does this count as breaking single responsibility principle? As in the jetpack class, even though functionality is inherited and ovewritten, you are mixing equipping and flying responsibilities, correct?