EngineeringWiki
  • Introduction
  • Top level Overview of the application
  • FAQs
  • Back End
    • Agent Pipeline
    • Mention Pipeline
    • Profile Pipeline
    • Errors
    • Overview of the Mention/Profile/Cluster Process
    • Adding a New Service
    • Activity and Status Tracking
  • Setup
    • Overview
    • How to Setup Your Local Machine
    • Setup - Cloud Machine
    • Infrastructure
    • Docker
    • Bash Commands
    • Setting up front end in Ubuntu 16.04 desktop
  • Gems/Libraries
    • Bax
    • Creating fixtures for Unit Tests
    • Audienti-Retriever
    • Scour
    • Haystack
    • Audienti-Indexer
    • Audienti-Api
    • Handler
    • Blackbook
    • Allusion
  • Code
    • Multi-step Modal Wizard
    • Structure
    • Audienti DataTables
    • Javascript
      • Passing Props From Root
      • Looping in JS
      • Binding Actions to App
      • CSSTransitionGroup
      • Code Best Practices
      • Reducer Updating an Array with Item in Middle
      • Organizing Javascript
      • Filter Array by Id
    • Design Language
  • Working
    • PostgresSQL
    • S3
    • Terminology
    • Interview Tests
    • Application Descriptions
    • Best Practices
      • Code Organization
      • Code Documentation (using Yard)
      • Git Workflow
      • Tasks and Queues
      • Working in Backend
    • Profiles & Enrichment
      • Profile ID Rules
  • Management
    • API Management
    • Bastion
    • Splash Proxy
    • Rancher
      • OpenVPN Server
      • Traefik Reverse Proxy
  • Teams & Interviews
    • Interview Questions
  • Culture
    • What Makes a World Class Engineer
  • Situational Statuses
    • 2017-11-03
    • 2018-01-09
  • Operations
Powered by GitBook
On this page
  1. Working
  2. Best Practices

Code Organization

  • Use a code editor with Rubocop enabled. Ensure that your setup generally matches the DHH version of Rubocop.

  • Opt for Factories instead of big controllers, particularly for complex actions. Creating and deleting items often will use factories in lieu of complex interactions in controllers. (i.e. keywords_factory).

  • A Class should have a single argument, args, which should be set to an args or args hash that as attr_readable. Then, the parameters of this options hash should be exposed as methods on the class. This keeps the class flexible, and allows us to add parameters without having to redefine the interface anywhere.

  • Complex items where you have 3 or 4 attributes on a method, and 20 or 30 lines of code, should be refactored into their own classes. Opt for a new class in lieu of a complex method when in doubt.

  • Comment each method with at least 1 line of code about what it does. If its complex, or performs a complex interaction, explain what the method does above the method in comments.

  • If a class has more than 200 lines, it might need to be refactored into smaller classes. Often, larger items should be broken into smaller items so that each class can do 1 thing. These are also easier to document and test, and provide reusable hooks.

PreviousBest PracticesNextCode Documentation (using Yard)

Last updated 7 years ago