-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Home
Sam Joseph edited this page Oct 20, 2015
·
9 revisions
- https://pragprog.com/articles/tell-dont-ask
- separation of concerns
- inappropriate intimacy
code
- don't mix interface with logic ++++
- SMS Functionality should not be in restaurant, should be in wrapper class ++
- avoid hard coding menu +++
- use inject where possible +++
- don't do anything more complex than specified in the brief ++++
- credentials in env variables +++
- indentation ++++
- move magic numbers to constant ++
- prefer attr_reader over attr_accessor ++
- single responsibility ++
- avoid long methods +
- avoid classes, methods, variables that are not used
- avoid numbers with + on front - phone numbers
- prefer attr_reader over def var; @var; end
- prefer [] over Array.new
- do short methods
- delete commented code
- remove empty lines
- prefer hashes with key: value to :key => value
- no need to do "== false" or "== true" in ruby
- avoid comments
- modules are object so should be CamelCase
- do end for multiple line blocks, {} for single
- early raise errors
- avoid code that's never executed
- prefer shorter descriptive method names (no need for get and set)
- descriptive variable names
- returns don't need assignments
- only raise for exceptional behaviour
- DRY things out
- match up variable names for least surprise, e.g. dishes for array of dishes, rather than food_holder
- avoid doing things that will throw hard to understand errors in corner cases, i.e. unplanned things
- avoid regrabbing reference to same object when you already have reference
tests
- do test first +
- avoid hard coding to data that may change
- move rspec var declarations to lets
- ensure each test has an expect - and ideally no more than one
- ensure that errors are checked by name in tests
- VCR or webmock is overkill in this challenge - prefer stubbing out individual methods
- make sure object under test is not double