C
C#2mo ago
Potassium

inheritance vs nested class

Suppose i want to create a Resources class. There are three type of resources: string resources, drawable resources, xml resources. Which one is better to implement the resources class: inheritance or nested class ? With inheritance, i create abstract class Resources, then create another class for each type of resources which inherit from Resources. With nested class, i create a static class Resources, then create a non-static class inside the Resources class for each resources types. For example, Resources.String, Resources.Drawable, etc.
3 Replies
Potassium
PotassiumOP2mo ago
Each class only share a small amount of functionally and is mostly different from each other.
Angius
Angius2mo ago
Well, in the first case you can have a List<Resource> that can contain StringResources and DrawableResources both In the second case... not
Potassium
PotassiumOP2mo ago
Ah yes i forgot about that txn
Want results from more Discord servers?
Add your server