Quantcast
Channel: Would this design of interface be considered bad? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Would this design of interface be considered bad?

$
0
0

I have written an interface for storing data as List/Map and have the ability to retrieve it back. Something like this:

public interface Repository {<K, V> void register(String typeTag, Key<K> key, V value);    void unregister(String typeTag);    void unregister(String... typeTags);    void unregister(Collection<String> typeTags);<T> void add(String typeTag, T object);<T> void add(String typeTag, Collection<T> object);<T, K> T get(String typeTag, Key<K> key);<T, U, K> Map<T, U> getAsMap(String typeTag, Collection<Key<K>> keys);<T, U> Map<T, U> getAsMap(String typeTag);<T, K> List<T> getAsList(String typeTag, Collection<Key<K>> keys);<T> List<T> getAsList(String typeTag);<T, K> Map<String, T> get(Collection<String> typeTags, Collection<Key<K>> keys);<T> T remove(String typeTag, T object);    void clear(String typeTag);    void clear();<U, V> Map<U, V> map(String typeTag1, String typeTag2) throws IllegalMappingException;<U, V, K> Map<U, V> map(String typeTag1, String typeTag2, Collection<Key<K>> keys) throws IllegalMappingException;<U, V> Map<U, V> map(String typeTag1, Criteria<U> type1Criteria, String typeTag2, Criteria<V> type2Criteria) throws IllegalMappingException;}

Now, I have well thought up the purpose of this interface and that can be defined through basically the following methods:

register(), unregister(), add(), get(), remove(), clear() and map()

But, as you can see there are overloaded versions of these methods that support taking and giving back data in Collections. These can be classified as "convenience" methods(as it seemed to me). But it makes me wonder that the implementor is going to have to implement these methods as compulsion and there are just too many of these to implement. I personally got the feeling that the design is putting too much onto the interface and the "burden" should be reduced somewhat.

First of all,

Is this design really bad?

What things/strategy should I take into consideration/apply and keeping what in mind to change this design before I continue to expand the hierarchy.

EDIT:

I am only looking for solution in Java 7 and less.


Viewing all articles
Browse latest Browse all 2

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>