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
Each class only share a small amount of functionally and is mostly different from each other.
Well, in the first case you can have a
List<Resource>
that can contain StringResource
s and DrawableResource
s both
In the second case... notAh yes i forgot about that txn