From Conditionals to Polymorphism
A conditional that keeps growing is a design problem, not a style problem. How to turn each branch into an object, one green step at a time.
In-depth articles on Ruby, Rails, and software engineering, built around original, worked examples you can learn from.
A conditional that keeps growing is a design problem, not a style problem. How to turn each branch into an object, one green step at a time.
Three rules turn duplication into abstractions through tiny steps, and catch false abstractions before they ever reach the code.
Creating objects is a responsibility too. What problem a factory actually solves, how the Simple Factory differs from the GoF's Factory Method, and how Ruby simplifies both because classes are objects.
Faced with a new problem, the elegant solution is almost always premature. Why simple code that passes the tests is the best starting point, and how to get there with TDD.
How to write Ruby tests that survive refactoring: what to test, what to ignore, and how to keep doubles from going stale.
Building complex objects in Ruby with composition and modules as roles, and knowing when each one beats inheritance for your design.
When to reach for duck typing and when for inheritance in Ruby. Template Method, hook messages, and the signals that point to a hidden abstraction.
Shift the focus from classes to conversations: sequence diagrams, stable interfaces, the Law of Demeter, and practical decoupling techniques in Ruby.
Learn how to implement the Singleton pattern in Ruby: built-in module, manual approach, thread safety, the class variable trap, and dependency injection.
Explore the philosophy behind software design: preserving changeability, measuring code friction, and balancing technical debt with over-engineering.
The Dependency Inversion Principle in Ruby: what it really means, when to use dependency injection, and when to keep your code simple.
How to apply the Interface Segregation Principle in Ruby, and why taking it too far can hurt your design. Practical examples and trade-offs.
Master the Liskov Substitution Principle in Ruby. Learn to spot structural violations, handle duck typing, and write better object-oriented code.
Explore the Open-Closed Principle in Ruby through practical examples using inheritance and the Strategy pattern. Learn how to balance strict SOLID adherence with pragmatic design decisions.
Master Value Objects in Ruby using the modern Data.define class. Learn about immutability, value equality, and how to eliminate boilerplate code for cleaner, safer domain modeling.
Should a Ruby class do just one thing? Explore the Single Responsibility Principle, cohesion, and when to split classes through practical examples.
Master the N+1 problem in Active Record. Understand when to use joins, includes, or both to optimize Rails database queries and boost performance.
The complete Ruby testing tutorial: understand fundamentals by building a test framework, then explore Minitest, RSpec, and Rack::Test with practical examples.
A step-by-step tutorial for building a Sinatra web application in Ruby. Covers routes, ERB templates, sessions, and REST principles to create a full CRUD to-do list app.
Build a complete, functional URL shortener from scratch with Ruby and Rack. This tutorial guides you in creating a real-world web application with a solid foundation to build upon.
Learn how to implement persistent connections in Ruby using Rack, from streaming bodies and Server-Sent Events (SSE) to real-time WebSockets, with clear examples.
Rack: Understand core concepts, routing, middleware basics, and learn how to create your own middleware step by step with examples.
ERB is a Ruby templating system to embed Ruby code in HTML. Learn how it works, with examples and step-by-step rendering instructions.
Explore Ruby’s libraries ecosystem, covering the Core Library, Standard Library, RubyGems, Bundler, how to load libraries, and manage dependencies.
Learn why the preinstalled Ruby on macOS is outdated, unsupported, and incompatible with modern gems.
Learn how to install Ruby on any OS with this step-by-step guide! Discover tips for managing multiple Ruby versions and optimizing your development setup with Ruby on Rails.
Tailwind CSS can be installed and used in several ways. Let's take a look at the playground, the CDN and the compiler.
How to build a cookie bar step by step in Ruby on Rails, and only install cookies if the user gives consent.
How to seed your database in Rails step by step, with your own task to automate the process and using a gem to generate actual data.