Adding Templates


The HomeBrew libraries were not written using templates. I implemented templates for many of the data structures, including lists, directed graphs, and hashes. In time, these templated classes should be used in place of the current solution, which is to derive everything from a common base virtual class, Object, and to use typecasting. This is not to say that everything shouldn't be derived from the Object class, but that typecasting rules can be better enforced and that code is easier to read when templates are used.

For instance, given the "typecasting from the Object class" solution, in the following code:

List *myList;
BDDnode *headNode = (BDDnode *)myList->Head();
someone reading this code for the first time realizes that myList is a list of BDDnode's only after seeing the statement where the typecast is performed. In the following code:
List<BDDnode> *myList;
BDDnode *headNode = myList->Head();
it is clear that myList is a list of BDDnode's.