| Java Spring 2006 - HW3 FAQ |
|   Java Prog Home   |   HW3 Assignment |
+ date interface
|
Question: | I think I'm missing something, I don't see why we are making the required interface for PIMEntities that have a date associated with them - what's up with that? |
|
Answer: | You (probably) are not missing anything. The point of the interface is that as long as you are defining classes that have something in common, you should formalize the commonality. If there is something in common with some other subset of the PIMEntities it would make sense to formalize that in an additional interface as well. Consider how you would write the code if you were asked to display your schedule according to your list of PIMEntitys. You could just go through the list looking for specific kinds of PIMEntitys (Todos, Appointments) and grab the date from each (using code specific to PIMTodos, PIMAppointments, etc). Now someone adds a new kind of PIMEntity, say a PIMSpringBreakParty class (which has a date associated with it). You would need to rewrite the code that displays your schedule to include this new type of PIMEntity. If you just used the same interface, you could have written the code once so that it could work with any kind of PIMEntity that had a date (and implemented the interface). So - you are right that you don't really need the interface to write your manager program - but the idea is to practice good software engineering, if there is something common about related classes, formalize this in an interface. |