DEV Community

Discussion on: Intro to OOP: Ruby 'One to Many' vs 'Many to Many'

Collapse
 
kwstannard profile image
Kelly Stannard

Thank you for taking the time to write this. There are a few problems with this approach though if you don't mind.

  • User objects know about the Account class, Account.all, and Account.all.select, causing three couplings.
  • Exposed class variables are effectively global variables and global variables cause a lot of tricky errors when you least expect it. Any globally accessible thing should be constant at runtime.
  • It seems like a re-implementation of an object-relational mapping but without the relational database. ORMs are more of a necessary evil than a good pattern. OOP prefers direct references between objects rather than filtering through global lists.

Hopefully that is helpful. I would recommend, if you haven't already, Sandi Metz for learning more about OOP as her writing is very accessible and informative.

Regards,
kwstannard