Practicing Ruby

Delightful lessons for dedicated programmers


Welcome to the world's largest open-access collection of lessons for experienced Ruby developers! Click on any article below to begin your journey, or learn more about this project.

Safely evaluating user-defined formulas and calculations Issue 8.2
Learn how to use the Dentaku formula parser/evaluator to run Excel-like formulas in Ruby programs (w. Solomon White) September 2015
Problem discovery comes before problem solving Issue 8.1
A brief story about why you should play around with problems before trying to solve them. March 2015
The anatomy of information in software systems Issue 7.10
Explore the tradeoffs involved in designing message formats, and the messy boundary between humans and computers. September 2014
A self guided course on streams, files, file formats, and sockets Issue 7.9
Explore UNIX-style stream processing, binary file formats, the Racc parser generator, and socket programming. March 2014
Sustainable maintenance: Focus on quality first Issue 7.8
Learn three useful practices for maintaining high quality open source projects (w. Eric Hodel) February 2014
Hunt the Wumpus: An exercise in creative coding Issue 7.7
Build Gregory Yob's classic text-based game from scratch, using the provided test suite as a guide. December 2013
Infrastructure automation by example Issue 7.6
Discover why infrastructure automation matters by exploring real Chef recipes. (w. Mathias Lafeldt) November 2013
Exploring low-level computing concepts with Ruby Issue 7.5
Implement a minimal simulator of the classic 6502 processor using nothing but JRuby. October 2013
Making incremental improvements to legacy systems Issue 7.4
Experience the challenge of overhauling one of Practicing Ruby's oldest features. (w. Jordan Byron) September 2013
Using data to explore questions about our lives Issue 7.3
Aggregate and analyze 500+ data points from a SMS-based mood study using R and Ruby. (w. Jia Wu) August 2013
Implementing a minimal HTTP server in Ruby Issue 7.2
Build just enough HTTP functionality from scratch to serve up static files. (w. Luke Francl) July 2013
Simulating tiny worlds for fun and profit Issue 7.1
Practice exploratory programming by modeling forest fires, rabbit populations, and diseases. June 2013
A low cost approach to working on side projects Issue 6.10
Save time by building a standalone feature before designing a complete product. May 2013
Avoiding brittleness in data munging projects Issue 6.9
Process data and generate reports without writing unmaintainable spaghetti code. April 2013
From adhoc script to object-oriented program Issue 6.8
Gradually convert a "throwaway" procedural program into a well-defined domain model. April 2013
The Law of Demeter: Some archaeological notes Issue 6.7
Explore the history of a classic design principle and how it relates to Ruby. (w. David A. Black) March 2013
Cleaning up bloated method interfaces Issue 6.6
Tame a complex method interface using keyword arguments and parameter objects. March 2013
Debugging without the doom and gloom Issue 6.5
Use stack traces, the Pry console, and tests to hunt bugs with confidence. (w. Carol Nichols) February 2013
Code reuse in Ruby: It's complicated! Issue 6.4
Learn the costs and benefits of the many ways that Ruby lets you reuse code. February 2013
A gentle introduction to actor-based concurrency Issue 6.3
Solve "Dining Philosophers" using mutex locks, then do it again using actors. (w. Alberto F. Capel) January 2013
A self-guided tour of an interesting codebase Issue 6.2
Practice your code reading skills by walking through a small GUI client to the GNU Go game engine. January 2013
Parsing JSON the hard way Issue 6.1
Learn about low-level parser and compiler tools by implementing a JSON parser. (w. Aaron Patterson) January 2013
An adventure in prototypes Issue 5.10
Build a text adventure game and a prototype-based object model, at the same time! (w. Avdi Grimm) December 2012
Simulating the emergent behavior of ant colonies Issue 5.9
Explore how simple rules for individuals can yield complex group behavior by simulating an ant colony. November 2012
Expanding your code reading horizons Issue 5.8
See how much even a few dozen lines of code can tell you about a programming language. November 2012
Understanding the relationships between objects Issue 5.7
Learn how to model dependencies, notifications, adjustments, and internal object relationships. October 2012
Guidelines for growing a stable codebase Issue 5.6
Discover the process we use for continuously improving (w. Jordan Byron) October 2012
Process spawning patterns Issue 5.5
Implement Ruby's system and backticks methods using the fork/exec pattern. (w. Jesse Storimer) October 2012
Building the API: Choices and challenges Issue 5.4
Consider the design tradeoffs between the JSON API and hypermedia API styles. (w. Carol Nichols) September 2012
Event loops demystified Issue 5.3
Build a Node.js/EventMachine-style event loop in roughly 150 lines of Ruby code. (w. Magnus Holm) September 2012
Temporal coupling and the Law of Demeter Issue 5.2
See how NASA JPL's take on the Law of Demeter simplifies building robust asynchronous code. August 2012
A practical application of basic statistical methods Issue 5.1
Crunch some numbers to see how Olympic medal wins relate to GDP and population. (w. Jia Wu) August 2012
Spiking is not cowboy coding Issue 4.12.4
Search for the boundary lines between organized chaos and wild, unstructured hacking. July 2012
Mock objects deeply influence design Issue 4.12.3
Learn the rules that you need to follow in order to use mock objects as an effective design tool. July 2012
Refactoring is not redesign Issue 4.12.2
Discover how the differences between refactoring and redesign affect testing strategies. July 2012
End-to-end testing is essential Issue 4.12.1
Build acceptance tests that reflect application behavior, rather than implementation details. July 2012
Lessons learned from my TDD self-study Issue 4.12
Revisit the reasons for Gregory's 90-day self-study on TDD, and see the results. July 2012
Responsibility-centric vs. data-centric design Issue 4.11
Work through two approaches to object modeling and examine their tradeoffs. (w. Greg Moeck) July 2012
Implementing the Active Record pattern, Part 2 Issue 4.10
Consider using "object-oriented mixins" to reduce inheritance-related problems in ActiveRecord. July 2012
The hidden costs of inheritance Issue 4.9
Think through some problems with inheritance-based modeling and then try a few related exercises. June 2012
Implementing the Active Record pattern, Part 1 Issue 4.8
Build a basic foundation to serve as the groundwork for implementing an ActiveRecord-style ORM. June 2012
Writing confident code Issue 4.7
Develop intention-revealing code that is confident about its responsibilities. (w. Avdi Grimm) June 2012
Persisting relations in a polyglot world Issue 4.6
Explore some non-traditional persistence mechanisms and their uses. (w. Piotr Szotkowski) May 2012
Solving the "Scoring Predictions" kata Issue 4.5
Work through a coding puzzle and learn some fun tricks along the way. (w. James Edward Gray II) May 2012
Tricks for working with text and files Issue 4.4
Tear apart a minimal clone of the Jekyll blog engine in search of helpful Ruby idioms. May 2012
What are the costs and benefits of TDD? Issue 4.1
Think through how to evaluate the impact of test-driven development on your work. April 2012
Lessons learned from coding in the danger zone Issue 3.10
Establish a few survival skills for working in hostile programming environments. March 2012
Using games to practice domain modeling Issue 3.9
Learn about modeling non-trivial business logic by implementing Minecraft's crafting table. February 2012
Criteria for disciplined inheritance, Part 2 Issue 3.8
Discover how Barbara Liskov's concept of "behavioral subtypes" apply to object modeling in Ruby. February 2012
Criteria for disciplined inheritance, Part 1 Issue 3.7
See how M. Sakkinen's notion of "Disciplined Inheritance" in 1989 still applies to modern Ruby code. February 2012
Framework design and implementation, Part 2 Issue 3.6
Explore some lessons learned the hard way in developing the Newman mail framework. February 2012
Framework design and implementation, Part 1 Issue 3.5
Dig through the Newman mail framework's source code in search of useful patterns and practices. February 2012
Building a better Turing tarpit Issue 3.4
In this issue, we improve the design of the Brainf*ck interpreter that was introduced in Issue 3.3 January 2012
Exploring the depths of a Turing tarpit Issue 3.3
Read the code for a simple Brainf*ck interpreter and think about how it might be improved. January 2012
Patterns for building excellent examples Issue 3.2
Learn how to write code samples that clearly communicate ideas to other programmers. January 2012
The qualities of great software Issue 3.1
See what ISO/IEC 9126 has to say about software quality, and how its metrics apply to Ruby code. January 2012
Thoughts on "Arguments and Results", Part 2 Issue 2.15
Work through result objects inspired by James Noble's classic "Arguments and Results" paper. November 2011
Thoughts on "Arguments and Results", Part 1 Issue 2.14
Work through argument objects inspired by James Noble's classic "Arguments and Results" paper. November 2011
Working with binary file formats Issue 2.12
Read and write bitmap files using only a few dozen lines of Ruby code. November 2011
Domain specific API construction Issue 2.11
Master classic Ruby DSL design patterns by ripping off well-known libraries and tools. November 2011
From requirements discovery to release Issue 2.10
Watch a small game project develop from the brainstorming phase to its first public release. October 2011
Building Unix-style command line applications Issue 2.9
Build a basic clone of the 'cat' utility while learning some Ruby idioms for command line applications. October 2011
Ruby and the singleton pattern don't get along Issue 2.8
Model the singleton pattern in seven different ways, without discovering an elegant solution. October 2011
"Unobtrusive Ruby" in Practice Issue 2.7
Explore ideas from Mike Burns's "Unobtrusive Ruby" blog post via practical code samples. October 2011
Learning new things step-by-step Issue 2.6
Build a simple arcade game in 13 tiny steps. September 2011
Thoughts on regression testing Issue 2.5
Benefit from two lessons about regression testing that were learned the hard way. September 2011
Building Enumerable & Enumerator in Ruby Issue 2.4
Learn about Ruby's powerful iteration tools by implementing some of its functionality yourself. September 2011
A closure is a double edged sword Issue 2.3
Discover why the closure property can sometimes lead to hard-to-spot memory leaks. September 2011
How to attack sticky problems Issue 2.2
Work through a few lessons that will help you find a starting point whenever you feel stuck. August 2011
Ways to load code Issue 2.1
Explore the strengths and weaknesses of the many code loading mechanisms in Ruby. August 2011
Structural Design Patterns Issue 1.26
Examine a use case for each of the classic structural design patterns laid out by the Gang of Four. February 2011
Creational Design Patterns Issue 1.25
Examine a use case for each of the classic creational design patterns laid out by the Gang of Four. February 2011
Connascence as a Software Design Metric Issue 1.24
Work through code samples inspired by Jim Weirich's "Building Blocks of Modularity" presentation. February 2011
SOLID Design Principles Issue 1.23
Work through code samples inspired by Sandi Metz's "SOLID Object-oriented Design" presentation. February 2011
How to practice, Part 2 Issue 1.22
See an example of how the practice methods outlined in Issue 1.21 can be applied to a real project. January 2011
How to practice, Part 1 Issue 1.21
Discover a new way to practice your coding skills by asking yourself the right questions. January 2011
Thoughts on Mocking, Part 2 Issue 1.20
Explore a few good uses of mock objects from a non-mockist's perspective. January 2011
Thoughts on Mocking, Part 1 Issue 1.19
Consider how the ideas from Martin Fowler's "Mocks aren't Stubs" can be applied to Ruby. January 2011
Dirty Little Secrets about Testing Issue 1.18
Take a look at some dark corners of the traditional testing dogma. January 2011
Interesting Ruby Hacker-Writers Issue 1.17
Find out which Ruby hackers consistently write great content worth reading. January 2011
Interesting Ruby Hackers Issue 1.16
Find out which Ruby hackers consistently write great code worth reading. January 2011
Duck Typing in Practice, Part 2 Issue 1.15
Examine real uses of Ruby's duck-typing capabilities in various open source projects and Ruby itself. December 2010
Duck Typing in Practice, Part 1 Issue 1.14
Investigate the three main ways of doing type checking in Ruby, then work on some related exercises. December 2010
Obfuscations of Christmas Past Issue 1.13
Tear apart an obfuscated Ruby program from Christian Neukirchen to learn some neat tricks. December 2010
Rapid Prototyping Issue 1.12
Build a tiny prototype of a tetris game on the command line. December 2010
Uses for Modules, Part 4 Issue 1.11
Explore the use of mixins for customizing individual objects. December 2010
Addendum to Uses For Modules, Part 3 Issue 1.10.a
Learn the subtle differences between "extend self", "def self.method", and "module_function". December 2010
Uses for Modules, Part 3 Issue 1.10
See how modules can be used as namespaced function bags, and as singleton objects. December 2010
Uses for Modules, Part 2 Issue 1.9
Use mixins as an alternative to multiple inheritance to augment class definitions. December 2010
Uses for Modules, Part 1 Issue 1.8
Use modules as namespaces for your libraries and applications. December 2010
Meditations on Bad and Good Code, Part 2 Issue 1.7
Read through a cleaned up version of the ugly "Tic Tac Toe" game created in Issue 1.5 December 2010
Meditations on Bad and Good Code, Part 1 Issue 1.6
Build an ugly tic-tac-toe game by writing the entire implementation as a single procedural script. December 2010
Testing Private Methods Issue 1.5
Understand why testing private methods can be a code smell. November 2010
Writing Configurable Applications, Part 2 Issue 1.4
Build dynamic Ruby-based configuration objects. November 2010
Writing Configurable Applications, Part 1 Issue 1.3
Learn what not to do when configuring applications, then explore a simple YAML-based configuration. November 2010
Ruby's method lookup path, Part 2 Issue 1.2
Use your knowledge of Ruby's lookup path to determine where to add methods in a program. November 2010
Ruby's method lookup path, Part 1 Issue 1.1
Discover the complicated, multi-step dance that is the Ruby method lookup path. November 2010