Skip to content

Refactoring BundleSet Interface Proposal

Andy Berry edited this page Apr 24, 2015 · 4 revisions

The BundleSet interface currently offers the following methods:

public BundlableNode getBundlableNode();
	
public List<LinkedAsset> seedAssets();
	
public List<LinkedAsset> getLinkedAssets();
	
public List<Asset> getAssets(String... prefixes);
	
public <AT extends Asset> List<AT> getAssets(List<String> prefixes, Class<? extends AT> assetType);
	
public List<Asset> getAssets(List<String> prefixes, List<Class<? extends Asset>> assetTypes);
	
public List<SourceModule> getSourceModules();
	
public <AT extends SourceModule> List<AT> getSourceModules(Class<? extends AT> assetType);
	
public List<SourceModule> getSourceModules(List<Class<? extends SourceModule>> assetTypes); 

There are 2 possible issues that I would like to point out:

  1. Assets may not be retrieved without specifying the prefixes. There is no method to retrieve all available assets, no matter the prefix.
  2. It is not clear what differentiates tha last 7 methods within the interface, because the return types are all types that extend each other.

My suggestions would be the following:

  1. Adding a method for retrieving all assets no matter the prefix, while maintaining the method requiring a prefix parameter.
  2. Reduce the number of functions that retrieve different types of assets. For example, for the last function, getSourceModules, the function returns a List<SourceModule>. Since SourceModule extends LinkedAsset, which in turn extends Asset, couldn't we instead use the same method for retrieving these Assets and then checking what subclass they belong to?

A proposed new interface

public BundlableNode bundlableNode();

public List<LinkedAsset> seedAssets();

public List<Asset> assets(String... prefixes);

public <AT extends Asset> List<AT> List<? extends AT> assets(List<String> prefixes, List<Class<? extends AT>> assetTypes);
Clone this wiki locally