On Tue, Feb 17, 2009 at 3:45 PM, Henry <[email protected]> wrote:

>
> The Room object is getting bloated, what should I do?
>
> Room has Windows, and you guys advised me to use Room.closeWindow().
> That's what I did.  However, instead of one getWindow() function in
> Room, Room now has 10 methods related to operations for Window.


Why? What are these 10 methods that you feel anyone interacting with a room
needs to individually call to manipulate the room's windows?


>
>
> Now Room also has an owner of type User , and owner handles the login
> (), changePassword(), etc.
> Room has an owner, that makes sense.
> Which solution's better now?
>
> Solution 1:  // 1 getOwer() method in Room
>
> Room.getOwner().changePassword(oldPassword, newPassword)
> Room.getOwner().validatePassword(password)
> Room.getOwner().setName(newName)
>
>
> Solution 2:  // 3 methods in Room
>
> Room.changeOwnerPassword(oldPassword, newPassword)
> Room.validateOwnerPassword(password)
> Room.setOwnerName(newName)
>

Both of these seem ridiculous, it would be silly to go through the room to
change the owner's password. If you want useful advice I'd say come up with
a more realistic scenario. The answers depend, as always, on the context
that the objects need to be used within.


>
> How about... Plan?  Let's say Plan has method isEnable(featureName).
> The view layer needs to call this function to determine which Tab to
> show.
> Room has a plan, that makes sense.  (One user can have many Rooms,
> each Room has a plan)
>

I have no idea what a "Plan" is.


>
>
> Solution 1:  // 1 getPlan() method
>
> Room.getPlan().isEnable("customizeWindow")
> Room.getPlan().isEnable("selectStyle")
> Room.getPlan().isEnable("ceilingFan")
>
>
> Solutions 2:
> Room.canCustomizeWindow()
> Room.canSelectStyle()
> Room.hasCeilingFan()
>
> Now I'm confused.  Do you guys still think solution 2 is the preferred
> choice?  Even thought it can make my Room object bloated with several
> times more methods?


No, if the room object becomes nothing but a series of delegating method
calls then it isn't doing anything useful. If this is the case, either the
Room is incorrect responsibilities or you're interacting with the wrong
object.

Again, if you can leave the arbitrary nature of these scenarios and present
a concrete set of use cases and requirements you'll get more concrete
advice.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to