bristolkr / assignments

TIY homework, mostly basic Ruby files from first week
0 stars 0 forks source link

Assignment 9-2 - Mixins #40

Open ambethia opened 9 years ago

ambethia commented 9 years ago

Week 9 - Assignment 2

Mixins and ActiveSupport::Concern

We're going to use ActiveSupport::Concern to create a mixin to alter the behavior of something in our app. E.g., you might extract the tagging functionality in your blog to be a generic Taggable concern that you could extract for use in another app (or even make into a gem/engine). "Mixins" like this help us reduce redundancies and organize code even if the concern is only used in one class.

Read about "composition over inheritance" and "single responsibility principle" for more on the philosophical reasons we might do this.

Here are some recommended reads on the subject: