views:

97

answers:

1

Hi, I am building and sort of RSS reader in java as my first object-oriented program and would love some OO design tips.

I have a Reader class with a list of Feed objects for RSS feeds, and each Feed downloads news items into Article objects in an Articles list.

What I want to do is find a way to relate articles from multiple sources. To do this, each Article has a HashSet of its keywords, and I would like to compare all article's keywords against each other and keep a count of their matched keywords. If the count between two articles is quite high, I would like to group them in the output.

What is an efficient way to do a 'many-to-many' (?) comparison of the articles and track relative scores?

+2  A: 

A common approach in databases is to have a "linking" object, (commonly called a "link table" in database parlance) that links the objects together. In this case, you might have a "related feeds" object that would link together the elements that were related, maybe how closely related they were and the common words, etc. Without knowing more about what you want to do specifically, it is hard to say more, but in general linking objects are used to describe the relationship between two objects - in this, case the why of how they are related, not just that they are related.

aperkins
I have done this in a DB before, but I am confused about how to do this in a Java/OO manor. I am using a LinkedList to contain Feeds,which have a LinkedList to contain articles, which contain a set of keywords.My ideas are scattered, but I am currently pondering:*Should each article contain a list with other articles that it matches added to it? how would I add a count of word matches as a score? *Should there be a new class of ArticleLinks that has two article objects and a word match score? Should this be list instead?Ultimately i need to be able to sort all articles by their scores
Mobs
Not entirely sure, although if you want to keep the "link" information around, a linking class that describes the relationship is probably your best bet.
aperkins
thank you, i'll give it a go.
Mobs