Why isn't Balloon open?
#849
Unanswered
nikclayton
asked this question in
Q&A
Replies: 1 comment
-
|
Because modern and clean code should always favor composition over inheritance. I would suggest looking into different creation patterns. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Why isn't
Balloonan open class?This question is prompted by an experiment I'm doing. I anticipate having many balloons in the app, and using the "Persistence" feature to only show each one once.
For that to work I need to give each balloon its own preference name.
Having to create and manage each preference name feels like very tedious work, so I thought I should be able to:
Balloonsubclass for my app that sets various defaults, and overridespreferenceNameto returnthis::class.java.canonicalname. This ensures that each subclass of that gets a sensible preference name.Something like this:
This fails at the first hurdle, because
Balloonis final, and can't be subclassed from. It also doesn't implement an interface, so I can't implement that interface in myAppBalloon, and delegate to an underlying implementation either.Beta Was this translation helpful? Give feedback.
All reactions