
#Ruby
#Web_Application
#security
#Design_Patterns
#DSLs
Elevate your Ruby skills to an advanced level by deepening your understanding of the design principles, best practices, and trade-offs involved in implementation approaches to future-proof your Ruby applications
Anyone striving to become an expert Ruby programmer needs to be able to write maintainable applications.
Polished Ruby Programming will help you get better at designing scalable and robust Ruby programs, so that no matter how big the codebase grows, maintaining it will be a breeze.
This book takes you on a journey through implementation approaches for many common programming situations, the trade-offs inherent in each approach, and why you may choose to use different approaches in different situations.
You'll start by refreshing Ruby fundamentals, such as correctly using core classes, class and method design, variable usage, error handling, and code formatting. Then you'll move on to higher-level programming principles, such as library design, use of metaprogramming and domain-specific languages, and refactoring. Finally, you'll learn principles specific to web application development, such as how to choose a database and web framework, and how to use advanced security features.
By the end of this Ruby programming book, you'll be a well rounded web developer with a deep understanding of Ruby.
While most code examples and principles discussed in the book apply to all Ruby versions, some examples and principles are specific to Ruby 3.0, the latest release at the time of publication.
This book is for Ruby programmers who are comfortable in coding with Ruby but want to advance their skills by mastering the deeper principles and best practices behind writing maintainable, scalable, optimized, and well-structured Ruby code. This book won't teach you the basics of Ruby – you'll need intermediate knowledge and practical experience before you can dive in.
Table of Contents
1. Getting the Most out of Core Classes
2. Designing Useful Custom Classes
3. Proper Variable Usage
4. Methods and Their Arguments
5. Handling Errors
6. Formatting Code for Easy Reading
7. Designing Your Library
8. Designing For Extensibility
9. Metaprogramming and When to Use It
10. Designing Useful Domain-Specific Languages
11. Testing to Ensure Your Code Works
12. Handling Change
13. Using Common Design Patterns
14. Optimizing Your Library
15. The Database Is Key
16. Web Application Design Principles
17. Robust Web Application Security

Most Ruby programming books are aimed at teaching the reader how to program in Ruby. Polished Ruby Programming does not teach you how to program in Ruby. It assumes you already know how to program in Ruby, and discusses trade-offs between different approaches to programming in Ruby, and principles for deciding which trade-offs may make the most sense in certain cases.
Apart from focusing on these fundamental principles, I’ll also be highlighting principles for better library design, where you’ll be shown how best to design extensible plugin systems as well as how to approach metaprogramming, testing, refactoring, and even optimization.

I think the key takeaway in the book is that there isn't a single way to do things in Ruby!
There are many ways to accomplishing your goals, and each of them has trade-offs. I’ve tried to highlight important principles of Ruby programming so that you will be able to choose the appropriate trade-offs for your applications. There are only a few cases where the book strictly recommends against using certain parts of Ruby, such as class variables, and certain techniques, such as enforcing arbitrary limits on method/class size.

I've been a Ruby programmer for over 15 years, and during that time I've authored and maintained many Ruby libraries, with a few of them becoming popular. There are definitely parts of the book that are specifically aimed at Ruby programmers who develop libraries for other programmers to use, and my extensive experience in authoring and maintaining Ruby libraries was helpful in writing those sections.
Additionally, I became a Ruby committer a couple of years ago, and since then I have become very involved in fixing bugs in Ruby. Doing this has required me to learn much more about the internals of Ruby than most Ruby programmers are aware of. Knowledge of the internals was very important when writing many parts of the book, particularly about why some approaches to Ruby programming are faster than others.

My favorite part of the book is the extended discussion on implementing a plugin system for Ruby libraries in chapter 8. This is a technique that is not yet popular in Ruby libraries but has been gaining popularity over the last few years. I would like to see this technique spread to more Ruby libraries, as I believe it offers numerous advantages for not only the maintainers of the library but also the users of the library and other programmers who wish to extend the library. I hope that after reading the book, library developers will consider using a plugin system in their current libraries or in future libraries they develop.
About the Author
Jeremy Evans is a Ruby committer who focuses on fixing bugs in Ruby, as well as improving the implementation of Ruby. He is the maintainer of many popular Ruby libraries, including the fastest web framework (Roda) and fastest database library (Sequel). His libraries are known not just for their performance, but also for their code quality, understandability, documentation, and how quickly any bugs found are fixed. For his contributions to Ruby and the Ruby community, he has received multiple awards, such as receiving the prestigious RubyPrize in 2020 and being chosen as a Ruby Hero in 2015. He has given presentations at over 20 Ruby conferences. In addition to working on Ruby, he is also a committer for the OpenBSD operating system.









