Tweeted yesterday by Anthony Green (https://twitter.com/anthonycgreen): What will the post-Rails contraction be that will lead us to designing good systems?#GOOS or#FP ?http://www.youtube.com/watch?v=NftT6HWFgq0 -@garybernhardtThe screencast dates back to June 2012. Just posting this for people like me who might have missed it.
describe Sweeper do
context "when a subscription is expired" do
let(:bob) do
stub(:active => true, :paid_at => 2.months.ago)
end
let(:users) { [bob] }
before { User.stub(:all) { users } }
if "emails the user" do
UserMailer.should_receive(:billing_problem).with(bob)
Sweeper.sweep
end
end
end
On Sun, Feb 10, 2013 at 11:50 PM, philip schwarz <philip.joh...@googlemail.com> wrote:Hello Philip,
Tweeted yesterday by Anthony Green (https://twitter.com/anthonycgreen): What will the post-Rails contraction be that will lead us to designing good systems?#GOOS or#FP ?http://www.youtube.com/watch?v=NftT6HWFgq0 -@garybernhardtThe screencast dates back to June 2012. Just posting this for people like me who might have missed it.
thanks for the link.I watched the video. His starting example gives me a strong sense of "this is not how I would do it". The example code I transcribed from the video isdescribe Sweeper do
context "when a subscription is expired" do
let(:bob) do
stub(:active => true, :paid_at => 2.months.ago)
end
let(:users) { [bob] }
before { User.stub(:all) { users } }
if "emails the user" do
UserMailer.should_receive(:billing_problem).with(bob)
Sweeper.sweep
end
end
endAs the GOOS examples are in Java, the above might look unfamiliar to people here, but I think you get the idea. The point is that the User class (which in Rails would perform the duty of the repository of users) is stubbed so that when we ask it for "all" the users, it returns the single user "bob", which is also a stub.
The presenter goes on to lament how this test, while being a fast and isolated unit test, might also be unreliable, due to the fact that it depends on stubbing and mocking behaviour that might be different in the production implementation.
Got more on Bernhardt's solution?
--
Tweeted yesterday by Anthony Green (https://twitter.com/anthonycgreen): What will the post-Rails contraction be that will lead us to designing good systems?#GOOS or#FP ?Capability vs. Suitability by Gary Bernhardt -@garybernhardt
The screencast dates back to June 2012. Just posting this for people like me who might have missed it.
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
And as for the conclusion: why not both? I've found that it works well to run functional business logic in GOOS-style "tell don't ask" objects that do event-driven I/O.
Object-orientation is better for the higher levels of a system, and functional programming is better for the lower levels.
"(...) we find that we tend towards different programming styles at different levels in the code. Loosely speaking, we use the message-passing style we’ve just described between objects, but we tend to use a more functional style within an object, building up behavior from methods and values that have no side effects.
Features without side effects mean that we can assemble our code from smaller components, minimizing the amount of risky shared state. Writing large-scale functional programs is a topic for a different book, but we find that a little immutability within the implementation of a class leads to much safer code and that, if we do a good job, the code reads well too".