1 minute read

Disclaimer: There’s lots of awesome books regarding OOP and how to write a good code (for example, 99 bottles of OOP, but there are tons of them)!

However, books take longer time to read, so here I attempted to compose a list of small but very useful articles which address the most crucial (IMO) problems.


OOP

Code smells list
most frequent non-trivial ones: Feature envy, Primitive obsession, Data class (lots of articles across the web, a couple I was able to recall below)

FeatureEnvy

PrimitiveObsession - awesome video

related to DataClass code smell: Anemic domain model anti-pattern

Tell-don’t-ask

Composition vs inheritance, 4 articles:

SOLID

A million of articles, what I was able to find in 2 minutes:

Typical abstractions

https://codeclimate.com/blog/7-ways-to-decompose-fat-activerecord-models/

https://www.sitepoint.com/7-design-patterns-to-refactor-mvc-components-in-rails/ (the same but with better syntax highlighting)

Overkill for small tasks, but good in bigger projects: dry-rb family
For example, on the last project we used dry-container, dry-auto-inject, dry-validation, dry-schema, dry-struct (and I think we could also use dry-events instead of self-made implementation). Recommend to take a look at, there are some useful abstractions.

Testing

Good general article about testing pyramid

Rspec-specific: a lot of people overuse fancy stuff like let, Let’s not helps to understand how to keep the balance between them and pure ruby functions to make specs better

Misc

Readable code

Tags: ,

Updated: