Def Solution2 Room HAS A window sounds correct.
window shouldn't care about a room. Maybe you'll want windows in your car too Sorry for abrupt reponse - working on a bad bug! Alan ________________________________ From: Henry <[email protected]> To: CFCDev <[email protected]> Sent: Thursday, February 12, 2009 6:49:38 PM Subject: [CFCDEV] OO question, how should I model this? Let's say.. there's a Room. Room has Window, and Door. Room has a state (empty, not empty). And this Room is smart that it only lets you close the Window when it is not empty. So.. we have: Room.isEmpty() Window.open() Window.close() Now... since Window.close() needs to check if room is empty first, what should be a better solution? // Solution1: Room.init() Window.init(room) // window has reference to Room Window.close() // checks if Room is empty first by calling room.isEmpty() > Room.getWindow().close() // Solution2: Room.init(Window window) Window.init() // window has no reference to Room Window.close() // will close itself w/o checking > Room.closeWindow() // Room object checks if it isEmpty(), if yes, then it > calls window.close() What do you guys think? Which one is the better solution? Why? base on which OO principle? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
