On Tue, Jun 6, 2017 at 5:29 PM, Justin Mclean <jus...@classsoftware.com> wrote:
> Hi, > > > In FlexJS we have a preference towards utility classes. > > So say we have existing bead A and we want to add some functionality to > to. In order to use utility classes we would need to modify bead A and pull > out some of the code into a utility class so bead B can use it. > > This will increase the size/runtime cost to existing people using bead A. > Is this accectable? > Yes, there will be a size cost, which is why the inheritance approach is better than Utils approach for Beads. *Utils approach:* Bead A supports feature X Bead B needs to support feature X and Y Create a Util class called FeatureXAndY Bead A calls util:FeatureXAndY (Now Bead A loads code for unnecessary feature Y) Bead B calls util:FeatureXAndY *Inheritance approach:* Bead A supports feature X Bead B needs to support feature X and Y Bead A has code for feature X alone (no extra code) Bead B extends Bead A and adds code for feature Y (no extra code) Moreover, no extra util class to maintain.