That code violates Tell, Don't Ask..
You could also say it exhibits the feature envy smell.
(Violating Tell, Don't Ask and having feature envy are pretty much two sides of the same coin.)
That code violates Tell, Don't Ask..
You could also say it exhibits the feature envy smell.
(Violating Tell, Don't Ask and having feature envy are pretty much two sides of the same coin.)
The smell is stubbing the System Under Test (SUT).
Sure! Symbol-to-proc is what you want here:
users.select(&:admin?)
Note that we couldn't use this if admin?
took an argument, which is kind of a bummer.
Callbacks (particularly those with side effects like sending an email or updating a record) can easily get you in trouble.
Further reading:
Looks like an iceberg class to me.
Now keep in mind! A smell doesn't necessarily mean something is wrong. It just means you should give it a sniff to see if fixing it would improve the design.
That's a decorator, yo!
I want to read more about decorators.
I want to watch a video where someone teaches me about decorators.
The method shown is inject
, (aka reduce
).
I love inject
, and you should too!
Jay Fields loves inject
so much he wrote a love letter to it.
Hello there fine madam or sir!
I have a short quiz for you. It won't take long.
By the way, don't worry if there are questions you can't answer. Lots of people will be struggling along with you, so don't feel bad. You're not alone.
Let's begin!
Do you recognize the method for which this is the (simplified) source?