3

weekly learning

Posted by ilake on August 20, 2016

“strive 8/13 ~ 8/20”

Use

Read

Book

  • Rails.AntiPatterns

    • Model
      • AntiPattern: Voyeuristic Models
        • follow the Law of Demeter
          • In Rails, this could be summed up as “use only one dot.” => class-level delegate method, This method provides a shortcut fondicating that one or more methods that will be created on your object are actually provided by a related objectr
        • Push All find() calls into finder on the model
          • use scoped
        • keep finders on their own model
      • AntiPattern: Fat Models
        • delegate responsibility to new classes
          • composed_of
        • make use of modules
        • reduce the size of large transaction blocks
          • callback, nested attributes
      • AntiPattern: spaghetti SQL
        • use your ActiveRecord associations and finders effectively
          • as much as possible using sql on own model, others use association to handle it
        • leanr and love the scope method
        • use a full-text search engine
      • AntiPattern: duplicate code duplication
        • extract into module
          • template pattarn => use module, and some must implement method => define and execute a class that is missing implementations of template methods
        • write a plugin
        • metaprograming
    • Domain Modeling
      • AntiPattern: authorization astronaut
        • simplify with simple flags
      • AntiPattern: the million-model march
        • denormalize into text fields
          • when model have the column like state, and need have some method to check state value => use meta-programing to define_method “#{state}?”
        • make use of rails serialization
          • save in hash
    • Views
      • AntiPattern: PHPitis
        • learn about the view helpers that come with rails
        • add useful accessors to your models
        • extract into custom helpers
      • AntiPattern: Markup Mayhem
        • make use of the rails helpers
        • use haml
    • Controllers
      • AntiPattern: Homemade Keys
        • use clearance
        • use authlogic
      • AntiPattern: Fat Controller
        • use active record callbacks and setters
          • default values => on migration
          • effective callback use
          • identification of unnecessary code
        • move to a presenter
      • AntiPattern: Bloated Sessions
        • store references instead of instances
      • AntiPattern: Monolithic Controllers
        • embrace REST
      • AntiPattern: Controller of Many Faces
        • refactor non-restful actions into a separate controller
      • AntiPattern: A Lost Child Controller
        • make use of nested resources
      • AntiPattern: Rat’s Nest Resources
        • use separate controllers for each nesting
      • AntiPattern: Evil Twin Controllers
        • use rails 3 responders
    • Services
      • AntiPattern: Fire and Forget
        • konw what exceptions to look out for
      • AntiPattern: Sluggish Services
        • move the task to the background
      • AntiPattern: Pitiful Page Parsing
        • use a gem => nokogiri
      • AntiPattern: Successful Failure
        • obey the http codes
      • AntiPattern: Kraken Code Base
        • divide into confederated applications
    • Using Third-Party Code

      • AntiPattern: Recutting the Gem
        • look for a gem first
      • AntiPattern: Amateur Gemologist
        • follow TAM (tests, activity, maturity)
      • AntiPattern: Vendor Junk Drawer
        • prune irrelevant or unused gems
      • AntiPattern: Miscreant Modification
        • consider vendored code sacrosanct
    • Testing

      • AntiPattern: Fixture Blues
        • make use of factories
        • refactor into contexts
      • AntiPattern: Lost in Isolation
        • watch your integration points
      • AntiPattern: Mock Suffocation
        • tell, don’t ask
      • AntiPattern: Untested Rake
        • extract to a class method
      • AntiPattern: Unprotexted Jewels
        • write normal unit tests without rails
        • load only the parts of rails you need
        • brake out the atom bomb
    • Scaling and Deploying
      • AntiPattern: Scaling Roadblocks
        • build to scale from the start
    • Databases
      • AntiPattern: Disappearing Assets
        • make use of the system directory
      • AntiPattern: Sluggish SQL
        • add indexes
        • reassess your domain model
      • AntiPattern: Painful Performance
        • don’t do inruby what you can do in sql
        • move processing into background jobs
      • AntiPattern: Messy Migrations
        • never modify the up method on a committed migration
        • never use external code in a migration
        • always provide a down method in migrations
      • AntiPattern: Wet Validations
        • eschew constraints in the database
    • Building for Failure

      • AntiPattern: Continual Catastrophe
        • fail fast
      • AntiPattern: Unaudible Failures
        • never fail quietly