| There's a saying in the OOA/D literature: "You can never have too many classes." Why are you trying to limit the number of classes you define, Christopher? Mark Guzdial |
| I think that a key class would be a great idea. It provides for future felxibility. Say you suddenly want to encrypt all of your key cards. Without a Key class you would have to add decrypting messages into the Lock class. That would be a viable solution but I think it would be better design to have the Key decrypt itself. Jared Parsons |
| The key class is something I considered but discarded for this reason: When implementing an actual hotel lock system the key is a physical object and not represented in software. Instead it sends data into the program as input, like a user typing on a keyboard. Instead, I would make a class called keyReader which has some method that catches the event of a card being swiped and then invokes the proper methods using the data from the card. Nate Weimer |
| Aah, I see your point, Christopher. Okay, then for a REAL, SPECIFIC implementation, what are ALL the classes you'd create – both concrete and abstract? That's what this question is asking. Mark Guzdial |
| Anybody know how a real hotel door with a card key works? It's actually quite fascinating. No database is involved at all. Each lock knows a sequence of random, big, prime numbers, arranged in a circular buffer. When you push the key in, the door compares the number on the card to the "current" number. If it matches, the door opens. If it doesn't match, check the next number in the sequence. If it matches, then that number becomes the "current," the old one no longer works, and the door opens. Mark Guzdial |
| Jesse, why would the key have an insert service? Is it the responsibility of the key to be inserted? Mark Guzdial |
| Good point, Nate. As long as one understands that the KeyReader is an object, not the verb of reading. Mark Guzdial |