Gmail-like labelling system
I am looking into a number of ways to implement a labelling system similar to the one in Gmail. Basically I have a Resource at the lowest level and I would like to provide a number of organisational groupings for that resource in the form of labels. If anyone has implemented something like that I would like to hear your views. My idea is to have within the Resource instance a List<Label>
. I need to have an efficient mechanism in order to do开发者_Python百科 very fast searches based on the labels or based on the resources.
Thanks Dimitris
Nope, I wouldn't do that. I'd think about maintaining two dictionaries, Label -> HashSet<Resource>
and Resource -> HashSet<Label>
. This will give you fast lookup in both directions. Obviously you should encapsulate this.
Also, whatever you do, you shouldn't embed it in your Resource
. It's a resource, and it's maintaining its labels? No. Single responsibility and all that.
精彩评论