That’s not what abstract does.
“abstract” means “by my royal decree, all attempts to make an instance of this class must cause compile error and prevent the program from being built”. It is not indication, it is enforcement.
In your example, there’s zero reason to make Person abstract because it would basically mean that in your world only Bankers and Warriors are allowed to exist. I somehow doubt that this is what you had in mind.
Abstract is usually used to provide base class with blank virtual methods. For example:
[RequireComponent(typeof(UnityEngine.UI.Text)]
public abstract class DataDisplayBase: MonoBehavior{
UnityEngine.UI.Text text = null;
void Start(){
text = GetComponent<UnityEngine.UI.Text>();
}
public abstract string getDisplayString();
void Update(){
if (text)
text.text = getDisplayString();
}
}
Then you do.
public class HelloDisplay: DataDisplayBase{
public override string getDisplayString(){
return "Hello";
}
}
And in case of unity you can also do your person/banker thing without inheritance.
public class Banker{
public Person personData;
}
This would allow multiple different Bankers and Warriors to use same basic parameter block.
Then comes a question - what are you going to do if a person is both banker and warrior. C# does not allow multiple inheritance. Or what are you going to do if a banker should turn into a warrior.
That moves us close to database design, in all honesty, but it is still something worth pondering.
One the most common novice programming errors is overuse of inheritance.
The decide that a Cat should inherit from Mammal, Mammal from Animal, animal from Actor, actor from Object and Object from Thing. Then they waste ton of time making beautiful class hierarchies except that making hierarchies beautiful does not improve the program behavior in any way.
So it is a good idea to keep in mind, that a class, if exists, should be doing something, and also think about how can you get rid of hierarchies completely.
And then you can do this:
Everything is a SceneObject. Nothing inherits from SceneObject. A Cat is a SceneObject that has a Mesh in shape of the cat, has a Skeleton used by that mesh, an Animator that drives the skeleton, and Behavior that drives both Thing and Animator. It can also play Sounds attached to it and has Collider.that prevents it from falling through the world.
No hierarchies or very shallow hierarchies.(2-3 levels deep)
No hierarchies.