This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Due to the instructions, I have to implement a method -- create(). The description tells me that I should allow user to insert a new record or reuse a deleted one. However, this method must throw a DuplicateKeyException which is not specified in the description.
I read the data file and found that the data record does not have primary key field (I have to use the index of the record location as primary key to uniquely identify a record). From my understanding, I think only when a new record and an existing record have identical contents in all the fields, a DuplicateKeyException will be thrown out.
However, from the name of the Exception, it implies that the Exception should be thrown when a new record has a key duplicating the key of an existing record. Again, the problem is: there is not nature primary key, there cannot be any primary key violence. Am I right?