3 ms·
Are these all subclasses of a Bubbles class? I think that'd be the natural place for a custom new method that figures out which subclass to construct based on t
by matheusmoreira 7y ago
Are these all subclasses of a Bubbles class? I think that'd be the natural place for a custom new method that figures out which subclass to construct based on the parameters.
In Java, an interface could have a static method that returns concrete implementations of itself.
- scroot 7y agoIt's even better. If it's just making stuff, you don't even need `BubbleMachine` if you have the `Bubbles` base class. You can add creation method on the class side of `Bubbles` like so: `Bubbles class >> #newGum` ^ GumBubbles new `Bubbles class >> #newSoap` ^ SoapBubbles new The difference here is that the base class still serves as a true base: it will have all the common functionality for various kinds of bubbles