reset password
Author Message
rabbott
Posts: 1649
Posted 00:13 Oct 27, 2013 |

I have generalized TweetSet so that it is now the class OrderedSet[T]. An OrderedSet is a set of elements with an ordering relation. The type parameter T is the type of elements in the set.  The main OrderedSet class is abstract. The Empty and NonEmpty classes are subclasses of OrderedSet--just as they were subclasses of TweetSet

Given OrderedSet, a TweetSet becomes OrderedSet[Tweet]. The OrderedSet class includes the methods that are not Tweet-specific. The Tweet-specific functions have been put in a TweetSet object.

The files are available here. Please look at them. I would like to talk about them Thursday. This code implements the items discussed on the wiki for this week. It also includes additional useful OrderedSet[T] methods. 

The transition from TweetSet to OrderedSet[T] is a nice illustration of factoring a class into the parts that are specific to a particular problem and the parts that are more general. In this case, the more general parts (that deal with ordered sets) could usefully be made into its own class with a type parameter. 

Last edited by rabbott at 00:29 Oct 27, 2013.