@@ -28,7 +28,7 @@ Write a [good commit message](http://goo.gl/w11us).
28
28
* More information about commit (under 72 characters)
29
29
* More information about commit (under 72 characters)
30
30
31
- Share your branch:
31
+ Share your branch.
32
32
33
33
git push origin [branch]
34
34
@@ -130,6 +130,7 @@ Naming
130
130
* Avoid abbreviations.
131
131
* Avoid Hungarian notiation (` szName ` ).
132
132
* Avoid types in names (` user_array ` ).
133
+ * Name background jobs with a ` Job ` suffix.
133
134
* Name the enumeration parameter the singular of the collection.
134
135
* Name variables, methods, and classes with intention-revealing names..
135
136
* Treat acronyms as words in names (` XmlHttpRequest ` not ` XMLHTTPRequest ` ),
@@ -149,12 +150,24 @@ Design
149
150
* Don't swallow exceptions or "fail silently."
150
151
* Don't write code that guesses at future functionality.
151
152
* [ Exceptions should be exceptional] ( http://rdd.me/yichhgvu ) .
152
- * [ Keep the code simple] ( http://www.readability.com/articles /ko2aqda2 ) .
153
+ * [ Keep the code simple] ( http://rdd.me /ko2aqda2 ) .
153
154
* Limit the number of collaborators of an object.
154
155
* Prefer composition over inheritance.
155
156
* Prefer small methods. One line is best.
156
157
* Prefer small objects with a single, well-defined responsibility.
157
- * [ Tell, don't ask] ( http://robots.thoughtbot.com/post/27572137956/tell-dont-ask ) .
158
+ * [ Tell, don't ask] ( http://goo.gl/Ztawt ) .
159
+
160
+ Javascript
161
+ ----------
162
+
163
+ * Define functions that operate on ` window ` or DOM in scope of ` window ` .
164
+ * Initialize arrays using ` [] ` .
165
+ * Initialize empty objects and hashes using ` {} ` .
166
+ * Use ` CamelCase ` for prototypes, ` mixedCase ` for variables and functions,
167
+ ` SCREAMING_SNAKE_CASE ` for constants, ` _single_leading_underscore ` for
168
+ private variables and functions.
169
+ * Use ` data- ` attributes to bind event handlers.
170
+ * Use the [ module pattern] ( http://goo.gl/JDtHN ) to control method visibility.
158
171
159
172
Ruby
160
173
----
200
213
* Use ` Set ` over ` Array ` for arrays with unique elements. The lookup is faster.
201
214
* Use single-quotes for strings unless interpolating.
202
215
* Use ` unless boolean? ` instead of ` if !boolean? ` .
203
- * Use [ Factory Girl] ( https://github.com/thoughtbot/factory_girl ) for setting up
204
- complicated test data.
216
+ * Use [ Factory Girl] ( http://goo.gl/zCsF1 ) to set up test data.
205
217
206
218
Rails
207
219
-----
@@ -210,6 +222,8 @@ Rails
210
222
* Avoid ` member ` and ` collection ` routes.
211
223
* Avoid Single Table Inheritance.
212
224
* Deploy to [ Heroku] ( http://heroku.com ) .
225
+ * Don't change a migration after it has been committed unless it cannot be
226
+ solved with another migration.
213
227
* Don't invoke a model's class directly from a view.
214
228
* Don't use SQL or SQL fragments (` where('inviter_id is not null') ` ) outside of
215
229
models.
@@ -225,21 +239,24 @@ Rails
225
239
helpers.
226
240
* Put all copy text in models, views, controllers, and mailers in
227
241
` config/locales ` .
242
+ * Serve assets from S3 using [ asset_sync] ( http://goo.gl/m58tF ) .
228
243
* Set ` config.action_mailer.delivery_method = :test ` in the test environment.
244
+ * Set ` config.assets.initialize_on_precompile = false ` in
245
+ ` config/application.rb ` .
246
+ * Set default values in the database.
229
247
* Use ` _path ` over ` _url ` for named routes everywhere except mailer views.
248
+ * Use ` db/seeds.rb ` for bootstrap data, not migrations.
230
249
* Use ` def self.method ` over the ` named_scope :method ` DSL.
231
- * Use [ Foreman] ( https://github.com/ddollar/foreman ) to run the development
232
- server.
250
+ * Use [ Foreman] ( http://goo.gl/oy4uw ) to run the development server.
233
251
* Use ` I18n.t 'dot.separated.key' ` over
234
252
` I18n.t :key, :scope => [:dot, :separated] ` .
235
253
* Use [ Haml] ( http://haml-lang.com ) for view templates.
236
254
* Use ` has_and_belongs_to_many ` if all you need is a join table. Start simple.
237
- * Use namespaced locale lookup in the views by prefixing a period: ` t '.title' ` .
255
+ * Use namespaced locale lookup in views by prefixing a period: ` t '.title' ` .
238
256
* Use nested routes to express ` belongs_to ` relationships between resources.
239
257
* Use one ` ActionMailer ` for the app. Name it ` Mailer ` .
240
- * Use [ single recipient SMTP] ( https://gist.github.com/2042496 ) in the staging
241
- environment.
242
- * Use the default ` render 'partial' ` syntax over ` render :partial => 'partial' ` .
258
+ * Use [ single recipient SMTP] ( http://goo.gl/FWdhG ) in staging environment.
259
+ * Use the default ` render 'partial' ` syntax over ` render partial: 'partial' ` .
243
260
* Use the ` :only ` option to explicitly state exposed routes.
244
261
245
262
Database
@@ -254,21 +271,21 @@ Database
254
271
* Create a read-only [ Heroku Follower] ( http://goo.gl/xWDMx ) for your
255
272
production database. If a Heroku database outage occurs, Heroku can use the
256
273
follower to get your app back up and running faster.
274
+ * Index all foreign keys.
257
275
* Use the Heroku Follower database for analytics to limit reads on the primary
258
276
database.
259
277
260
- Javascript
261
- ----------
278
+ Background Jobs
279
+ ---------------
262
280
263
- * Define functions that operate on ` window ` or DOM in scope of ` window ` .
264
- * Initialize arrays using ` [] ` .
265
- * Initialize empty objects and hashes using ` {} ` .
266
- * Use ` CamelCase ` for prototypes, ` mixedCase ` for variables and functions,
267
- ` SCREAMING_SNAKE_CASE ` for constants, ` _single_leading_underscore ` for
268
- private variables and functions.
269
- * Use ` data- ` attributes to bind event handlers.
270
- * Use the [ module pattern] ( http://yuiblog.com/blog/2007/06/12/module-pattern )
271
- to control method visibility.
281
+ * Define a ` PRIORITY ` constant at the top of the class.
282
+ * Define two public methods: ` self.enqueue ` and ` perform ` .
283
+ * Enqueue the job in ` self.enqueue ` [ like this] ( http://goo.gl/C7e54 ) .
284
+ * Put background jobs in ` app/jobs ` .
285
+ * Store IDs, not ` ActiveRecord ` objects for cleaner serialization. Re-find the
286
+ ` ActiveRecord ` object in the ` perform ` method.
287
+ * Subclass the job from ` Struct.new(:something_id) ` .
288
+ * Use [ ` Delayed::Job ` ] ( http://goo.gl/sRYju ) for background jobs.
272
289
273
290
Testing
274
291
-------
@@ -286,14 +303,12 @@ Testing
286
303
* Prefix ` context ` blocks names with 'given' when receiving input. Prefix with
287
304
'when' in most other cases.
288
305
* Run specs with ` --format documentation ` .
306
+ * Test backgroun jobs with a [ ` Delayed::Job ` matcher] ( http://goo.gl/bzBlN ) .
289
307
* Use a ` context ` block for each execution path through the method.
290
- * Use a [ Fake] ( http://robots.thoughtbot.com/post/219216005/fake-it ) to stub
291
- requests to external services.
292
- * Use ` before ` blocks to clearly define the 'setup' phase of the
293
- [ Four Phase Test] ( http://xunitpatterns.com/Four%20Phase%20Test.html ) .
308
+ * Use a [ Fake] ( http://goo.gl/YR7Hh ) to stub requests to external services.
309
+ * Use a ` before ` block to define phases of [ Four Phase
310
+ Test] ( http://goo.gl/J9FiJ ) .
294
311
* Use integration tests to execute the entire app.
295
- * Use literal strings or non-[ SUT] ( http://xunitpatterns.com/SUT.html ) methods
296
- in test expectations when possible.
312
+ * Use non-[ SUT] ( http://goo.gl/r5Ti2 ) methods in expectations when possible.
297
313
* Use one expection per ` it ` block.
298
- * Use stubs and spies (not mocks) in isolated tests to test only the object
299
- under test.
314
+ * Use stubs and spies (not mocks) in isolated tests.
0 commit comments