Skip to content

Instantly share code, notes, and snippets.

View r00k's full-sized avatar
💭
Working on Tuple (https://tuple.app)

Ben Orenstein r00k

💭
Working on Tuple (https://tuple.app)
View GitHub Profile
@r00k
r00k / a1.md
Last active April 5, 2016 19:49
Quizzy Question 2

Answer to Question 1

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.)

@r00k
r00k / a2.md
Last active November 23, 2015 19:13
Quizzy Question 3
@r00k
r00k / a3.md
Last active August 29, 2015 14:20
Quizzy Question 4

Answer to Question 3

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.

@r00k
r00k / a4.md
Last active April 3, 2016 10:53
Quizzy Question 5

Answer to Question 4

detect makes things a little shorter:

widgets.detect { |widget| widget.size > 3 }
@r00k
r00k / a5.md
Last active April 4, 2016 11:00
Quizzy Question 6
@r00k
r00k / a4.md
Last active March 7, 2016 10:05
Ruby Quiz Question 5

Answer to Question 4:

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.

@r00k
r00k / a3.md
Last active August 29, 2015 14:17
Ruby Quiz Question 4
@r00k
r00k / a1.md
Last active August 29, 2015 14:17
Ruby Quiz Question 3

Answer to Question 2:

The syntax shown is for required keyword arguments.

Here's an example:

def foo(bar:)
  puts bar
end
@r00k
r00k / a1.md
Last active August 29, 2015 14:17
Ruby Quiz Question 2

Answer to Question 1:

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.

@r00k
r00k / q1.md
Last active March 5, 2016 11:33
Ruby Quiz Question 1

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?