- Home /
Coding Question, extending a class with different methods
I'm trying to create an extendable class that has several methods that might not all be needed when the extending class implements it. What is the correct way to go about doing this? Should I break the methods down into small groups and extend the groups independently as needed? (IE, several interfaces that each just have related methods, and extend more than one interface when required)
I'm still somewhat new to C# so I don't know if there's already a way to create some sort of extendable feature that lets you pick and choose what methods that you want to implement and I just don't know what to search for in order to find the related info.
Thanks for any insights on this.
Answer by Casiell · Dec 06, 2019 at 07:18 AM
What you describe sounds exactly like a job for interfaces/abstract classes. Alternatively in Unity you may do it with different components attached to a game object, each responsible for a single, small functionality.
Both options are good, which one you choose depends on what you want to do with it
I had been using interfaces for something similar, I just didn't know if there was another, better tool for the purpose. It will be easy enough to use multiple interfaces when they are needed. Thanks for the reply.