Giter VIP home page Giter VIP logo

how-we-work's Introduction

JTology - How We Work

Values & Core Principles

Other Guides:

Base Strucutring Projects

Formatting/Conventions

Base styles guides:

Our updates:

  • Limit lines to 110 characters, in order to remove horizontal scrolling on GitHub when we are doing code review
  • Align parameters like:
# good (normal indent) PREFERABLE
def send_mail(source)
  Mailer.deliver(
    to: '[email protected]',
    from: '[email protected]',
    subject: 'Important message',
    body: source.text
  )
end

# not so bad
def send_mail(source)
  Mailer.deliver(
    to: '[email protected]', from: '[email protected]'
  )
end

# good, but DEPRECATED
def send_mail(source)
  Mailer.deliver(to: '[email protected]',
                 from: '[email protected]',
                 subject: 'Important message',
                 body: source.text)
end
  • Use prefix _ for memo variables:
class TestObject
  attr_reader :attr_name
  
  def attr_name
    @attr_name ||= lazy_calculation_for_attr_name
  end
  
  def public_method_with_memo
    @_public_method_with_memo ||= public_method_with_memo_calculcations
  end
end
  • Stick to Newlines section of Airbnb's Ruby style guide for grouping the code within methods.

Working with Bugs

  • Confirm on the master, the staging and finally on development environment.
  • Add tests with reproduced bugs before add fixes

Ruby on Rails Conventions

  • We use Decorators (in code we called them Carrier) as View and Form objects: introduction how to use them
  • We do not use full Presenters (TODO: add link to first post about them) with any tag generations
  • We do not overuse of Concerns
  • We do not overuse (in 99% of our code we do not see such stuff): send, &., **. To prevent misusage of Ruby Syntax Sugars [link]

Test Conventions

Principles

  • TDD
  • Clarity means that a test should serve as readable documentation for humans, describing the code being tested in terms of its public APIs.
  • A test is complete when its body contains all of the information you need to understand it, and concise when it doesn't contain any other distracting information.

Ref: Testing on the Toilet: What Makes a Good Test?

Rules

  • Tests First[link]
    • Use Black Box testing strategy (there is no other way to support TDD)[link]

      By ignoring the code (Black box testing), it demonstrates a different value system - the tests are valuable alone.

  • We use the meaningful names in the test cases. It makes easier to understand the business logic.[link]
# bad
def test_email_is_normalized
  user = User.create! email: '[email protected]'
  assert_equal '[email protected]', user.email
end

# good
def test_email_is_normalized
  user = User.create! email: ' [email protected]'
  assert_equal '[email protected]', user.email
end
# BAD
let!(:user_with_big_name) { ... }
let!(:user_with_small_name) { ... }

it 'this test use only user_with_big_name' { expects(response).to have(user_with_big_name) }
it 'this test use only user_with_small_name' { expects(response).to have(user_with_small_name) }
# GOOD
context 'with big name' do
  let(:user) { ... }
  
  it 'this test use only user_with_big_name' { expects(response).to have(user) }
end

context 'with small name' do
  let(:user) { ... }
  
  it 'this test use only user_with_small_name' { expects(response).to have(user) }
end
# BAD
setup do
  big_file_with_all_users = compile_file_from_users(User.all)
end

test 'this test use only user_with_big_name' { assert_includes big_file_with_all_users, 'magic string with all big letter' }
test 'this test use only user_with_small_name' { assert_includes big_file_with_all_users, 'magic string with all small letter' }
# GOOD
test 'this test use only user_with_big_name' do
  result = compile_file_from_users(User.new(name: 'Big Name'))
  assert_includes result, 'Big Name'
end

test 'this test use only user_with_small_name' do
  result = compile_file_from_users(User.new(name: 'Samll Name'))
  assert_includes result, 'Small Name'
end
  • No Dynamic Test generation.[link]
# BAD
{ string: 'zone_id', array: %w[zone_id], hash: { "0" => "zone_id" } }.each do |type, group_by|
  it "returns valid json if group_by is #{type}" do
  end
end
# GOOD
it "returns zone_id json if group_by is string" { }
it "returns [zone_id] json if group_by is array" { }
it "returns { '0' => 'zone_id' } json if group_by is hash" { }
  • Irrelevant Information[link]

    Message for reviewer:

    The test is exposing a lot of irrelevant details about the fixture that distract the test reader from what really affects the behavior of the subject under test.

describe 'PUT Update' do
  let!(:user) { create :user }

  # Bad
  it 'updates user' do
    attributes = { first_name: '..', last_name: '..', role: '..', email: '..' }
    put: :update, params: { attributes }
    expects(response.body).to eq attributes
  end

  # Good
  it 'updates first_name' do
    put: :update, params: { first_name: 'John Dou' }
    expects(response.body).to have_attribute { first_name: 'John Dou' }
  end

  it 'updates email' do
    put: :update, params: { email: '[email protected]' }
    expects(response.body).to have_attribute { email: '[email protected]' }
  end

Setup Development Environment

  • bin/setup - cold setup
  • bin/update - update environment on new code updates

Delivery Flow

Our flow is based on GitHub flow with Heroku Review

  • create PR (we convert issues into PR)
  • deploy PR to Heroku (we use Heroku Review to do this automatically)
  • verify on Heroku yourselves
  • ask verify, to code review and to merge (we have Code Review)

TODO/FIXME Notes

  • add issue on GitHub per each note
  • create TODO/FIXME note in the code
  • add in code's note link to GitHub's issue

Git/GitHub

Development Best Practices

Other Tools and Practices to use

Recomended Tutorials

Constraints which makes fun development

Tools:

  • Collaboration:
  • CI:
  • Server Configuation: Ansible
  • Deployments: Capistrano
  • Assets and File Uploads CDN hosting: AWS, CloudFront, Cloudinary (Images Uploads)
  • PAAS for Isolated Staging Testing: Heroku (Ruby on Rails apps), surge.sh (Static HTML)
  • Cache: Memcached/Redis Cloud from Redis Lab
  • JavaScript Base Frameworks: Stimulus, Vanilla JS, Vue.js, React
  • SCM: GitHub

how-we-work's People

Contributors

askel4dd avatar dgorodnichy avatar hnatt avatar katlavan avatar m1ndg8mer avatar mluts avatar obliviusm avatar pftg avatar sviridovsv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

how-we-work's Issues

Add Trivial Problems Solutions Guide

Need to have section or separate document where we will place trivial problems descriptions and how to fix them.

For example:

N+1 Problem

Short description, like we have extra queries

Diagnostic

We can review log file ourselves or setup gem bullet for auto-detection

Solution

Add include

References

  1. Some links for best posts about this problem

Communication

We should describe that we are talking with clients/other guys by using real world results.

  • for messages wot everyone should be answered by online user in next 15 min if no one has answered
  • all personal messages should be answered asap or provided feedback when it will be answered
  • [ ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.