Sandi Metz's Rules

In this episode, Ben and Joe discuss Sandi Metz's rules. You can read the summarized rules. Pull 1 Pull 2 Pull 3 Reek
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/sandi-metzs-rules

This is a little off-topic, but Iā€™m interested in the instantiation of the Review facade demonstrated in this screencast. Can you please describe the approach with the dependencies method used here.

Also I assume the exercise, revision etc are instance methods on the controller. Is that correct?

1 Like

Thanks for the discussion!

Iā€™m very interested in the concept of using automated ā€˜rulesā€™ to improve code quality. In fact, I recently set up ContinuousQuality.org as a resource for this, and have also made some contributions to the quality gem.

At the company I work for (Blacklane in Berlin) we have team of 6 developers, with a mix of levels from junior to senior. We started a new project recently and decided to use Reek from the very beginning, alongside RuboCop and rails_best_practices. (Co-incidentally, the team lead is the maintainer of Reek, Timo RĆ¶ĆŸner.)

Itā€™s been an interesting journey so far. There was certainly some initial frustration about the rules imposed by Reek. Writing very short methods was a big change for most of the team.

We have our CI system configured to fail the build if it doesnā€™t pass the quality checks. I know this is controversial, but itā€™s been very effective so far. It brought up some important discussions about OO design and refactoring. One of the first useful outcomes was to introduce a Parameter Object.

We break the rules when itā€™s appropriate to by adding exclusions to Reekā€™s configuration file, but only after careful thought and discussion.

It was also interesting to see youā€™re using pattr_reader which I assume is from attr_extras. Iā€™m often frustrated by writing boilerplate initiallizers and protected attr_readers, but I wasnā€™t sure if using something like pattr_reader is straying too far from idiomatic Ruby.

3 Likes

FYIā€¦ the three ā€œlinksā€ on the video page at Sandi Metz's Rules | Online Video Tutorial by thoughtbot (Pull1, Pull2, Pull3) are obviously placeholders that go nowhere and should be removed.

Thanks for a great session!

@JESii, I believe those links are to pull requests within the upcase repo on Github. You might need to give the Thoughtbot folks your Github username to get access to it.

In one of the Weekly Iterations it was said to keep method arguments to a maximum of 4? Doesnā€™t this dependency class break that rule?