Tell, don't ask
robots.thoughtbot.com
Tell, don't ask
1–10 of 88 posts
Re: Tell, don't ask
#2Re: Tell, don't ask
#3Incidentally, if this article blew your mind or if you're interested in Smalltalk, I can't recommend this book enough:
http://www.lulu.com/shop/andres-valloud/a-mentoring-course-o...
The author has a radical take on OO in Smalltalk and shows that going to absurd lengths to eliminate if-statements (well, ifTrue: et. al., because it's Smalltalk) can lead to both better readability and better performance.
Re: Tell, don't ask
#4Re: Tell, don't ask
#5Unit-testing the check_for_overheating inside SystemMonitor looks complicated... The "sound_alarms" call inside probably needs to be a reference to a "Speaker.sound_alarms", right? Why should the SystemMonitor be locked to the API of a Speaker? etc.
Re: Tell, don't ask
#6Re: Tell, don't ask
#7Re: Tell, don't ask
#8Re: Tell, don't ask
#9I really like the clean design of the site though, very fresh imo.
Re: Tell, don't ask
#10Going down this path seems to put your code at risk for dangerous mixing of concerns, in some cases. Unit-testing the check_for_overheating inside SystemMonitor looks complicated... The "sound_alarms" call inside probably needs to be a reference to a "Speaker.sound_alarms", right? Why should the SystemMonitor be locked to the API of a Speaker? etc.
The point is more about putting the behavior itself in the object. For unit testing, you'd want to move the individual tests into their own classes, letting the SystemMonitor be the glue that calls them and routes responses to the appropriate system.