• You can play with yourself. • You can play with your own toys (but you can't take them apart), • You can play with toys that were given to you. • And you can play with toys you've made yourself.
• Your method can call other methods in its class directly • Your method can call methods on its own fields directly (but not on the fields' fields) • When your method takes parameters, your method can call methods on those parameters directly. • When your method creates local objects, that method can call methods on the local objects.
def friends Friendship.friend_ids_of(@user) end def find_images_of(friends) Image.of(friends) end def apply_age_restritions_to(images) images.appropriate_for(@user.age) end def order_by(sorting) images.order(sorting) end def paginate(page) images.paginate(page) end def decorate(images) images.map { |image| ImageDecorator.new(image) } end
• Duplicated Code • Long Method • Large Class • Long Parameter List • Shotgun Surgery • Feature Envy • Data Clumps • Case Statements • Parallel Inheritance Hierarchies • Speculative Generality • Temporary Field • Message Chains • Middle Man • Alternative Classes with Different Interfaces • Refused Bequest • Comments • Repetitive Boilerplate • и т.н....