Avoiding Junk-Drawer Classes in Ruby

Because Ruby is an object-oriented language, we tend to model the world as a set of objects. We say that two integers (x and y) are a Point, and a Line has two of them.While this approach is often useful, it has one big problem. It privileges one interpretation of the data over all others. It assumes that x, and y will always be a Point and that you'll never need them to act as a Cell or Vector.What happens when you do need a Cell? Well, Point owns the data. So you add a your cell methods to Point. Over time you end up with a Point class that is a junk drawer of loosely-related methods.Junk-drawer classes are so common that we often accept them as inevitable and tack on a "refactoring" step to development. But what if we could avoid the problem in the first place?.
Avoiding Junk-Drawer Classes in Ruby #ruby #rubydeveloper #rubyonrails #classes https://rubyonrails.ba/single/avoiding-junk-drawer-classes-in-ruby

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles